summaryrefslogtreecommitdiff
path: root/lib/libc/crypt
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1997-03-27 23:26:29 +0000
committerJason Downs <downsj@cvs.openbsd.org>1997-03-27 23:26:29 +0000
commit5da4f628db97220480fa956df43b271fd31e8afb (patch)
treeef261b44c7fe33d75ee2eb766aa9e6433a8e323a /lib/libc/crypt
parentbd6623152e148d1d5531ae1f8b94dc44ff8b7407 (diff)
Make this code sane.
Diffstat (limited to 'lib/libc/crypt')
-rw-r--r--lib/libc/crypt/crypt.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/crypt/crypt.c b/lib/libc/crypt/crypt.c
index e28e94e42f6..c468d301a26 100644
--- a/lib/libc/crypt/crypt.c
+++ b/lib/libc/crypt/crypt.c
@@ -50,7 +50,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: crypt.c,v 1.7 1997/02/13 16:58:44 provos Exp $";
+static char rcsid[] = "$OpenBSD: crypt.c,v 1.8 1997/03/27 23:26:28 downsj Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -621,7 +621,7 @@ crypt(key, setting)
* and padding with zeros.
*/
q = (u_char *) keybuf;
- while (q - (u_char *) keybuf - 8) {
+ while ((q - (u_char *) keybuf) <= sizeof(keybuf)) {
if (*q++ = *key << 1)
key++;
}
@@ -650,7 +650,8 @@ crypt(key, setting)
* And XOR with the next 8 characters of the key.
*/
q = (u_char *) keybuf;
- while (q - (u_char *) keybuf - 8 && *key)
+ while (((q - (u_char *) keybuf) <= sizeof(keybuf)) &&
+ *key)
*q++ ^= *key++ << 1;
if (des_setkey((u_char *) keybuf))