=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/cipher.c,v retrieving revision 1.26 retrieving revision 1.26.2.2 diff -u -r1.26 -r1.26.2.2 --- src/usr.bin/ssh/cipher.c 2000/04/14 10:30:30 1.26 +++ src/usr.bin/ssh/cipher.c 2000/09/01 18:23:18 1.26.2.2 @@ -12,7 +12,7 @@ */ #include "includes.h" -RCSID("$Id: cipher.c,v 1.26 2000/04/14 10:30:30 markus Exp $"); +RCSID("$OpenBSD: cipher.c,v 1.26.2.2 2000/09/01 18:23:18 jason Exp $"); #include "ssh.h" #include "cipher.h" @@ -174,14 +174,15 @@ int ciphers_valid(const char *names) { - char *ciphers; + char *ciphers, *cp; 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))) { + ciphers = cp = xstrdup(names); + for ((p = strsep(&cp, CIPHER_SEP)); p && *p != '\0'; + (p = strsep(&cp, CIPHER_SEP))) { i = cipher_number(p); if (i == -1 || !(cipher_mask2() & (1 << i))) { xfree(ciphers); @@ -201,6 +202,8 @@ 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)))