зеркало из https://github.com/Azure/sonic-openssh.git
- 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:
Родитель
1a534ae97f
Коммит
0e3b87279c
|
@ -155,6 +155,10 @@
|
|||
- provos@cvs.openbsd.org 2002/01/13 17:27:07
|
||||
[ssh-agent.c]
|
||||
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
|
||||
|
@ -7303,4 +7307,4 @@
|
|||
- Wrote replacements for strlcpy and mkdtemp
|
||||
- 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.
|
||||
*/
|
||||
#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 "auth.h"
|
||||
#include "buffer.h"
|
||||
#include "packet.h"
|
||||
#include "xmalloc.h"
|
||||
#include "dispatch.h"
|
||||
|
@ -68,22 +69,25 @@ static KbdintAuthctxt *
|
|||
kbdint_alloc(const char *devs)
|
||||
{
|
||||
KbdintAuthctxt *kbdintctxt;
|
||||
Buffer b;
|
||||
int i;
|
||||
char buf[1024];
|
||||
|
||||
kbdintctxt = xmalloc(sizeof(KbdintAuthctxt));
|
||||
if (strcmp(devs, "") == 0) {
|
||||
buf[0] = '\0';
|
||||
buffer_init(&b);
|
||||
for (i = 0; devices[i]; i++) {
|
||||
if (i != 0)
|
||||
strlcat(buf, ",", sizeof(buf));
|
||||
strlcat(buf, devices[i]->name, sizeof(buf));
|
||||
if (buffer_len(&b) > 0)
|
||||
buffer_append(&b, ",", 1);
|
||||
buffer_append(&b, devices[i]->name,
|
||||
strlen(devices[i]->name));
|
||||
}
|
||||
debug("kbdint_alloc: devices '%s'", buf);
|
||||
kbdintctxt->devices = xstrdup(buf);
|
||||
buffer_append(&b, "\0", 1);
|
||||
kbdintctxt->devices = xstrdup(buffer_ptr(&b));
|
||||
buffer_free(&b);
|
||||
} else {
|
||||
kbdintctxt->devices = xstrdup(devs);
|
||||
}
|
||||
debug("kbdint_alloc: devices '%s'", kbdintctxt->devices);
|
||||
kbdintctxt->ctxt = NULL;
|
||||
kbdintctxt->device = NULL;
|
||||
|
||||
|
|
27
auth2.c
27
auth2.c
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
#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>
|
||||
|
||||
|
@ -588,31 +588,22 @@ static char *
|
|||
authmethods_get(void)
|
||||
{
|
||||
Authmethod *method = NULL;
|
||||
u_int size = 0;
|
||||
Buffer b;
|
||||
char *list;
|
||||
|
||||
buffer_init(&b);
|
||||
for (method = authmethods; method->name != NULL; method++) {
|
||||
if (strcmp(method->name, "none") == 0)
|
||||
continue;
|
||||
if (method->enabled != NULL && *(method->enabled) != 0) {
|
||||
if (size != 0)
|
||||
size += strlen(DELIM);
|
||||
size += 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);
|
||||
if (buffer_len(&b) > 0)
|
||||
buffer_append(&b, ",", 1);
|
||||
buffer_append(&b, method->name, strlen(method->name));
|
||||
}
|
||||
}
|
||||
buffer_append(&b, "\0", 1);
|
||||
list = xstrdup(buffer_ptr(&b));
|
||||
buffer_free(&b);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
18
compat.c
18
compat.c
|
@ -23,8 +23,9 @@
|
|||
*/
|
||||
|
||||
#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 "xmalloc.h"
|
||||
#include "compat.h"
|
||||
|
@ -182,24 +183,25 @@ proto_spec(const char *spec)
|
|||
char *
|
||||
compat_cipher_proposal(char *cipher_prop)
|
||||
{
|
||||
Buffer b;
|
||||
char *orig_prop, *fix_ciphers;
|
||||
char *cp, *tmp;
|
||||
size_t len;
|
||||
|
||||
if (!(datafellows & SSH_BUG_BIGENDIANAES))
|
||||
return(cipher_prop);
|
||||
|
||||
len = strlen(cipher_prop) + 1;
|
||||
fix_ciphers = xmalloc(len);
|
||||
*fix_ciphers = '\0';
|
||||
buffer_init(&b);
|
||||
tmp = orig_prop = xstrdup(cipher_prop);
|
||||
while ((cp = strsep(&tmp, ",")) != NULL) {
|
||||
if (strncmp(cp, "aes", 3) && strncmp(cp, "rijndael", 8)) {
|
||||
if (*fix_ciphers)
|
||||
strlcat(fix_ciphers, ",", len);
|
||||
strlcat(fix_ciphers, cp, len);
|
||||
if (buffer_len(&b) > 0)
|
||||
buffer_append(&b, ",", 1);
|
||||
buffer_append(&b, cp, strlen(cp));
|
||||
}
|
||||
}
|
||||
buffer_append(&b, "\0", 1);
|
||||
fix_ciphers = xstrdup(buffer_ptr(&b));
|
||||
buffer_free(&b);
|
||||
xfree(orig_prop);
|
||||
debug2("Original cipher proposal: %s", cipher_prop);
|
||||
debug2("Compat cipher proposal: %s", fix_ciphers);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
#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/md5.h>
|
||||
|
@ -991,22 +991,23 @@ authmethod_get(char *authlist)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#define DELIM ","
|
||||
|
||||
static char *
|
||||
authmethods_get(void)
|
||||
{
|
||||
Authmethod *method = NULL;
|
||||
char buf[1024];
|
||||
Buffer b;
|
||||
char *list;
|
||||
|
||||
buf[0] = '\0';
|
||||
buffer_init(&b);
|
||||
for (method = authmethods; method->name != NULL; method++) {
|
||||
if (authmethod_is_enabled(method)) {
|
||||
if (buf[0] != '\0')
|
||||
strlcat(buf, DELIM, sizeof buf);
|
||||
strlcat(buf, method->name, sizeof buf);
|
||||
if (buffer_len(&b) > 0)
|
||||
buffer_append(&b, ",", 1);
|
||||
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"
|
||||
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/bn.h>
|
||||
|
@ -480,9 +480,11 @@ destroy_sensitive_data(void)
|
|||
static char *
|
||||
list_hostkey_types(void)
|
||||
{
|
||||
static char buf[1024];
|
||||
Buffer b;
|
||||
char *p;
|
||||
int i;
|
||||
buf[0] = '\0';
|
||||
|
||||
buffer_init(&b);
|
||||
for (i = 0; i < options.num_host_key_files; i++) {
|
||||
Key *key = sensitive_data.host_keys[i];
|
||||
if (key == NULL)
|
||||
|
@ -490,16 +492,18 @@ list_hostkey_types(void)
|
|||
switch (key->type) {
|
||||
case KEY_RSA:
|
||||
case KEY_DSA:
|
||||
strlcat(buf, key_ssh_name(key), sizeof buf);
|
||||
strlcat(buf, ",", sizeof buf);
|
||||
if (buffer_len(&b) > 0)
|
||||
buffer_append(&b, ",", 1);
|
||||
p = key_ssh_name(key);
|
||||
buffer_append(&b, p, strlen(p));
|
||||
break;
|
||||
}
|
||||
}
|
||||
i = strlen(buf);
|
||||
if (i > 0 && buf[i-1] == ',')
|
||||
buf[i-1] = '\0';
|
||||
debug("list_hostkey_types: %s", buf);
|
||||
return buf;
|
||||
buffer_append(&b, "\0", 1);
|
||||
p = xstrdup(buffer_ptr(&b));
|
||||
buffer_free(&b);
|
||||
debug("list_hostkey_types: %s", p);
|
||||
return p;
|
||||
}
|
||||
|
||||
static Key *
|
||||
|
|
Загрузка…
Ссылка в новой задаче