- markus@cvs.openbsd.org 2002/01/13 17:57:37
[auth2.c auth2-chall.c compat.c sshconnect2.c sshd.c] use buffer API and avoid static strings of fixed size; ok provos@/mouring@
This commit is contained in:
parent
1a534ae97f
commit
0e3b87279c
|
@ -155,6 +155,10 @@
|
||||||
- provos@cvs.openbsd.org 2002/01/13 17:27:07
|
- provos@cvs.openbsd.org 2002/01/13 17:27:07
|
||||||
[ssh-agent.c]
|
[ssh-agent.c]
|
||||||
change to use queue.h macros; okay markus@
|
change to use queue.h macros; okay markus@
|
||||||
|
- markus@cvs.openbsd.org 2002/01/13 17:57:37
|
||||||
|
[auth2.c auth2-chall.c compat.c sshconnect2.c sshd.c]
|
||||||
|
use buffer API and avoid static strings of fixed size;
|
||||||
|
ok provos@/mouring@
|
||||||
|
|
||||||
|
|
||||||
20020121
|
20020121
|
||||||
|
@ -7303,4 +7307,4 @@
|
||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1767 2002/01/22 12:26:13 djm Exp $
|
$Id: ChangeLog,v 1.1768 2002/01/22 12:26:38 djm Exp $
|
||||||
|
|
|
@ -23,10 +23,11 @@
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: auth2-chall.c,v 1.15 2002/01/11 23:02:51 markus Exp $");
|
RCSID("$OpenBSD: auth2-chall.c,v 1.16 2002/01/13 17:57:37 markus Exp $");
|
||||||
|
|
||||||
#include "ssh2.h"
|
#include "ssh2.h"
|
||||||
#include "auth.h"
|
#include "auth.h"
|
||||||
|
#include "buffer.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "dispatch.h"
|
#include "dispatch.h"
|
||||||
|
@ -68,22 +69,25 @@ static KbdintAuthctxt *
|
||||||
kbdint_alloc(const char *devs)
|
kbdint_alloc(const char *devs)
|
||||||
{
|
{
|
||||||
KbdintAuthctxt *kbdintctxt;
|
KbdintAuthctxt *kbdintctxt;
|
||||||
|
Buffer b;
|
||||||
int i;
|
int i;
|
||||||
char buf[1024];
|
|
||||||
|
|
||||||
kbdintctxt = xmalloc(sizeof(KbdintAuthctxt));
|
kbdintctxt = xmalloc(sizeof(KbdintAuthctxt));
|
||||||
if (strcmp(devs, "") == 0) {
|
if (strcmp(devs, "") == 0) {
|
||||||
buf[0] = '\0';
|
buffer_init(&b);
|
||||||
for (i = 0; devices[i]; i++) {
|
for (i = 0; devices[i]; i++) {
|
||||||
if (i != 0)
|
if (buffer_len(&b) > 0)
|
||||||
strlcat(buf, ",", sizeof(buf));
|
buffer_append(&b, ",", 1);
|
||||||
strlcat(buf, devices[i]->name, sizeof(buf));
|
buffer_append(&b, devices[i]->name,
|
||||||
|
strlen(devices[i]->name));
|
||||||
}
|
}
|
||||||
debug("kbdint_alloc: devices '%s'", buf);
|
buffer_append(&b, "\0", 1);
|
||||||
kbdintctxt->devices = xstrdup(buf);
|
kbdintctxt->devices = xstrdup(buffer_ptr(&b));
|
||||||
|
buffer_free(&b);
|
||||||
} else {
|
} else {
|
||||||
kbdintctxt->devices = xstrdup(devs);
|
kbdintctxt->devices = xstrdup(devs);
|
||||||
}
|
}
|
||||||
|
debug("kbdint_alloc: devices '%s'", kbdintctxt->devices);
|
||||||
kbdintctxt->ctxt = NULL;
|
kbdintctxt->ctxt = NULL;
|
||||||
kbdintctxt->device = NULL;
|
kbdintctxt->device = NULL;
|
||||||
|
|
||||||
|
|
27
auth2.c
27
auth2.c
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: auth2.c,v 1.81 2002/01/11 13:39:36 markus Exp $");
|
RCSID("$OpenBSD: auth2.c,v 1.82 2002/01/13 17:57:37 markus Exp $");
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
|
@ -588,31 +588,22 @@ static char *
|
||||||
authmethods_get(void)
|
authmethods_get(void)
|
||||||
{
|
{
|
||||||
Authmethod *method = NULL;
|
Authmethod *method = NULL;
|
||||||
u_int size = 0;
|
Buffer b;
|
||||||
char *list;
|
char *list;
|
||||||
|
|
||||||
|
buffer_init(&b);
|
||||||
for (method = authmethods; method->name != NULL; method++) {
|
for (method = authmethods; method->name != NULL; method++) {
|
||||||
if (strcmp(method->name, "none") == 0)
|
if (strcmp(method->name, "none") == 0)
|
||||||
continue;
|
continue;
|
||||||
if (method->enabled != NULL && *(method->enabled) != 0) {
|
if (method->enabled != NULL && *(method->enabled) != 0) {
|
||||||
if (size != 0)
|
if (buffer_len(&b) > 0)
|
||||||
size += strlen(DELIM);
|
buffer_append(&b, ",", 1);
|
||||||
size += strlen(method->name);
|
buffer_append(&b, method->name, strlen(method->name));
|
||||||
}
|
|
||||||
}
|
|
||||||
size++; /* trailing '\0' */
|
|
||||||
list = xmalloc(size);
|
|
||||||
list[0] = '\0';
|
|
||||||
|
|
||||||
for (method = authmethods; method->name != NULL; method++) {
|
|
||||||
if (strcmp(method->name, "none") == 0)
|
|
||||||
continue;
|
|
||||||
if (method->enabled != NULL && *(method->enabled) != 0) {
|
|
||||||
if (list[0] != '\0')
|
|
||||||
strlcat(list, DELIM, size);
|
|
||||||
strlcat(list, method->name, size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
buffer_append(&b, "\0", 1);
|
||||||
|
list = xstrdup(buffer_ptr(&b));
|
||||||
|
buffer_free(&b);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
compat.c
18
compat.c
|
@ -23,8 +23,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: compat.c,v 1.56 2001/12/19 07:18:56 deraadt Exp $");
|
RCSID("$OpenBSD: compat.c,v 1.57 2002/01/13 17:57:37 markus Exp $");
|
||||||
|
|
||||||
|
#include "buffer.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
@ -182,24 +183,25 @@ proto_spec(const char *spec)
|
||||||
char *
|
char *
|
||||||
compat_cipher_proposal(char *cipher_prop)
|
compat_cipher_proposal(char *cipher_prop)
|
||||||
{
|
{
|
||||||
|
Buffer b;
|
||||||
char *orig_prop, *fix_ciphers;
|
char *orig_prop, *fix_ciphers;
|
||||||
char *cp, *tmp;
|
char *cp, *tmp;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (!(datafellows & SSH_BUG_BIGENDIANAES))
|
if (!(datafellows & SSH_BUG_BIGENDIANAES))
|
||||||
return(cipher_prop);
|
return(cipher_prop);
|
||||||
|
|
||||||
len = strlen(cipher_prop) + 1;
|
buffer_init(&b);
|
||||||
fix_ciphers = xmalloc(len);
|
|
||||||
*fix_ciphers = '\0';
|
|
||||||
tmp = orig_prop = xstrdup(cipher_prop);
|
tmp = orig_prop = xstrdup(cipher_prop);
|
||||||
while ((cp = strsep(&tmp, ",")) != NULL) {
|
while ((cp = strsep(&tmp, ",")) != NULL) {
|
||||||
if (strncmp(cp, "aes", 3) && strncmp(cp, "rijndael", 8)) {
|
if (strncmp(cp, "aes", 3) && strncmp(cp, "rijndael", 8)) {
|
||||||
if (*fix_ciphers)
|
if (buffer_len(&b) > 0)
|
||||||
strlcat(fix_ciphers, ",", len);
|
buffer_append(&b, ",", 1);
|
||||||
strlcat(fix_ciphers, cp, len);
|
buffer_append(&b, cp, strlen(cp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
buffer_append(&b, "\0", 1);
|
||||||
|
fix_ciphers = xstrdup(buffer_ptr(&b));
|
||||||
|
buffer_free(&b);
|
||||||
xfree(orig_prop);
|
xfree(orig_prop);
|
||||||
debug2("Original cipher proposal: %s", cipher_prop);
|
debug2("Original cipher proposal: %s", cipher_prop);
|
||||||
debug2("Compat cipher proposal: %s", fix_ciphers);
|
debug2("Compat cipher proposal: %s", fix_ciphers);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: sshconnect2.c,v 1.92 2001/12/28 15:06:00 markus Exp $");
|
RCSID("$OpenBSD: sshconnect2.c,v 1.93 2002/01/13 17:57:37 markus Exp $");
|
||||||
|
|
||||||
#include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
#include <openssl/md5.h>
|
#include <openssl/md5.h>
|
||||||
|
@ -991,22 +991,23 @@ authmethod_get(char *authlist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define DELIM ","
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
authmethods_get(void)
|
authmethods_get(void)
|
||||||
{
|
{
|
||||||
Authmethod *method = NULL;
|
Authmethod *method = NULL;
|
||||||
char buf[1024];
|
Buffer b;
|
||||||
|
char *list;
|
||||||
|
|
||||||
buf[0] = '\0';
|
buffer_init(&b);
|
||||||
for (method = authmethods; method->name != NULL; method++) {
|
for (method = authmethods; method->name != NULL; method++) {
|
||||||
if (authmethod_is_enabled(method)) {
|
if (authmethod_is_enabled(method)) {
|
||||||
if (buf[0] != '\0')
|
if (buffer_len(&b) > 0)
|
||||||
strlcat(buf, DELIM, sizeof buf);
|
buffer_append(&b, ",", 1);
|
||||||
strlcat(buf, method->name, sizeof buf);
|
buffer_append(&b, method->name, strlen(method->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return xstrdup(buf);
|
buffer_append(&b, "\0", 1);
|
||||||
|
list = xstrdup(buffer_ptr(&b));
|
||||||
|
buffer_free(&b);
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
24
sshd.c
24
sshd.c
|
@ -40,7 +40,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: sshd.c,v 1.222 2001/12/28 14:50:54 markus Exp $");
|
RCSID("$OpenBSD: sshd.c,v 1.223 2002/01/13 17:57:37 markus Exp $");
|
||||||
|
|
||||||
#include <openssl/dh.h>
|
#include <openssl/dh.h>
|
||||||
#include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
|
@ -480,9 +480,11 @@ destroy_sensitive_data(void)
|
||||||
static char *
|
static char *
|
||||||
list_hostkey_types(void)
|
list_hostkey_types(void)
|
||||||
{
|
{
|
||||||
static char buf[1024];
|
Buffer b;
|
||||||
|
char *p;
|
||||||
int i;
|
int i;
|
||||||
buf[0] = '\0';
|
|
||||||
|
buffer_init(&b);
|
||||||
for (i = 0; i < options.num_host_key_files; i++) {
|
for (i = 0; i < options.num_host_key_files; i++) {
|
||||||
Key *key = sensitive_data.host_keys[i];
|
Key *key = sensitive_data.host_keys[i];
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
|
@ -490,16 +492,18 @@ list_hostkey_types(void)
|
||||||
switch (key->type) {
|
switch (key->type) {
|
||||||
case KEY_RSA:
|
case KEY_RSA:
|
||||||
case KEY_DSA:
|
case KEY_DSA:
|
||||||
strlcat(buf, key_ssh_name(key), sizeof buf);
|
if (buffer_len(&b) > 0)
|
||||||
strlcat(buf, ",", sizeof buf);
|
buffer_append(&b, ",", 1);
|
||||||
|
p = key_ssh_name(key);
|
||||||
|
buffer_append(&b, p, strlen(p));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = strlen(buf);
|
buffer_append(&b, "\0", 1);
|
||||||
if (i > 0 && buf[i-1] == ',')
|
p = xstrdup(buffer_ptr(&b));
|
||||||
buf[i-1] = '\0';
|
buffer_free(&b);
|
||||||
debug("list_hostkey_types: %s", buf);
|
debug("list_hostkey_types: %s", p);
|
||||||
return buf;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Key *
|
static Key *
|
||||||
|
|
Loading…
Reference in New Issue