diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2000-05-22 18:42:02 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2000-05-22 18:42:02 +0000 |
commit | 86a24e2c7f3973e756847ad71874ef8674732158 (patch) | |
tree | 750aa603c73193204bff2ed5b8cfe42a75fc122c /usr.bin/ssh | |
parent | 88efda90023aa7986f7bce3b1c831233240ce4ee (diff) |
check strtok() != NULL; ok niels@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/cipher.c | 6 | ||||
-rw-r--r-- | usr.bin/ssh/compat.c | 8 | ||||
-rw-r--r-- | usr.bin/ssh/readconf.c | 8 | ||||
-rw-r--r-- | usr.bin/ssh/servconf.c | 6 |
4 files changed, 21 insertions, 7 deletions
diff --git a/usr.bin/ssh/cipher.c b/usr.bin/ssh/cipher.c index bcaff024db2..ca77c6d034d 100644 --- a/usr.bin/ssh/cipher.c +++ b/usr.bin/ssh/cipher.c @@ -12,7 +12,7 @@ */ #include "includes.h" -RCSID("$Id: cipher.c,v 1.26 2000/04/14 10:30:30 markus Exp $"); +RCSID("$Id: cipher.c,v 1.27 2000/05/22 18:42:00 markus Exp $"); #include "ssh.h" #include "cipher.h" @@ -178,7 +178,7 @@ ciphers_valid(const char *names) char *p; int i; - if (strcmp(names, "") == 0) + if (names == NULL || strcmp(names, "") == 0) return 0; ciphers = xstrdup(names); for ((p = strtok(ciphers, CIPHER_SEP)); p; (p = strtok(NULL, CIPHER_SEP))) { @@ -201,6 +201,8 @@ int cipher_number(const char *name) { int i; + if (name == NULL) + return -1; for (i = 0; i < sizeof(cipher_names) / sizeof(cipher_names[0]); i++) if (strcmp(cipher_names[i], name) == 0 && (cipher_mask() & (1 << i))) diff --git a/usr.bin/ssh/compat.c b/usr.bin/ssh/compat.c index 33e509cb89b..1dd0c39d224 100644 --- a/usr.bin/ssh/compat.c +++ b/usr.bin/ssh/compat.c @@ -28,7 +28,7 @@ */ #include "includes.h" -RCSID("$Id: compat.c,v 1.13 2000/05/08 17:42:24 markus Exp $"); +RCSID("$Id: compat.c,v 1.14 2000/05/22 18:42:01 markus Exp $"); #include "ssh.h" #include "packet.h" @@ -80,10 +80,12 @@ compat_datafellows(const char *version) int proto_spec(const char *spec) { - char *s = xstrdup(spec); - char *p; + char *s, *p; int ret = SSH_PROTO_UNKNOWN; + if (spec == NULL) + return ret; + s = xstrdup(spec); for ((p = strtok(s, SEP)); p; (p = strtok(NULL, SEP))) { switch(atoi(p)) { case 1: diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c index 2053c67aa2b..74570db316a 100644 --- a/usr.bin/ssh/readconf.c +++ b/usr.bin/ssh/readconf.c @@ -14,7 +14,7 @@ */ #include "includes.h" -RCSID("$Id: readconf.c,v 1.31 2000/05/08 17:12:15 markus Exp $"); +RCSID("$Id: readconf.c,v 1.32 2000/05/22 18:42:01 markus Exp $"); #include "ssh.h" #include "cipher.h" @@ -464,6 +464,8 @@ parse_int: case oCipher: intptr = &options->cipher; cp = strtok(NULL, WHITESPACE); + if (!cp) + fatal("%.200s line %d: Missing argument.", filename, linenum); value = cipher_number(cp); if (value == -1) fatal("%.200s line %d: Bad cipher '%s'.", @@ -474,6 +476,8 @@ parse_int: case oCiphers: cp = strtok(NULL, WHITESPACE); + if (!cp) + fatal("%.200s line %d: Missing argument.", filename, linenum); if (!ciphers_valid(cp)) fatal("%.200s line %d: Bad SSH2 cipher spec '%s'.", filename, linenum, cp ? cp : "<NONE>"); @@ -484,6 +488,8 @@ parse_int: case oProtocol: intptr = &options->protocol; cp = strtok(NULL, WHITESPACE); + if (!cp) + fatal("%.200s line %d: Missing argument.", filename, linenum); value = proto_spec(cp); if (value == SSH_PROTO_UNKNOWN) fatal("%.200s line %d: Bad protocol spec '%s'.", diff --git a/usr.bin/ssh/servconf.c b/usr.bin/ssh/servconf.c index 57f7050dbb4..4e3e5cc7967 100644 --- a/usr.bin/ssh/servconf.c +++ b/usr.bin/ssh/servconf.c @@ -12,7 +12,7 @@ */ #include "includes.h" -RCSID("$Id: servconf.c,v 1.40 2000/05/08 17:12:15 markus Exp $"); +RCSID("$Id: servconf.c,v 1.41 2000/05/22 18:42:01 markus Exp $"); #include "ssh.h" #include "servconf.h" @@ -588,6 +588,8 @@ parse_flag: case sCiphers: cp = strtok(NULL, WHITESPACE); + if (!cp) + fatal("%s line %d: Missing argument.", filename, linenum); if (!ciphers_valid(cp)) fatal("%s line %d: Bad SSH2 cipher spec '%s'.", filename, linenum, cp ? cp : "<NONE>"); @@ -598,6 +600,8 @@ parse_flag: case sProtocol: intptr = &options->protocol; cp = strtok(NULL, WHITESPACE); + if (!cp) + fatal("%s line %d: Missing argument.", filename, linenum); value = proto_spec(cp); if (value == SSH_PROTO_UNKNOWN) fatal("%s line %d: Bad protocol spec '%s'.", |