summaryrefslogtreecommitdiff
path: root/src/lib/libc/crypt
diff options
context:
space:
mode:
authorderaadt <>2006-04-03 19:55:49 +0000
committerderaadt <>2006-04-03 19:55:49 +0000
commitfd6d62e96b81f055cd4c12eab824a3d30d264979 (patch)
treed6cfcdfa80d95e82266b8027a0533a632d065d73 /src/lib/libc/crypt
parentb191a1bc418ee9a7b5c00effd8c2a765697490e8 (diff)
downloadopenbsd-fd6d62e96b81f055cd4c12eab824a3d30d264979.tar.gz
openbsd-fd6d62e96b81f055cd4c12eab824a3d30d264979.tar.bz2
openbsd-fd6d62e96b81f055cd4c12eab824a3d30d264979.zip
be more careful with atoi() result; ok otto
Diffstat (limited to 'src/lib/libc/crypt')
-rw-r--r--src/lib/libc/crypt/bcrypt.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libc/crypt/bcrypt.c b/src/lib/libc/crypt/bcrypt.c
index 6e1ae04e1b..cdc2dd05a6 100644
--- a/src/lib/libc/crypt/bcrypt.c
+++ b/src/lib/libc/crypt/bcrypt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bcrypt.c,v 1.19 2004/12/22 17:33:25 otto Exp $ */ 1/* $OpenBSD: bcrypt.c,v 1.20 2006/04/03 19:55:49 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> 4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@@ -183,6 +183,7 @@ bcrypt(const char *key, const char *salt)
183 u_int8_t ciphertext[4 * BCRYPT_BLOCKS] = "OrpheanBeholderScryDoubt"; 183 u_int8_t ciphertext[4 * BCRYPT_BLOCKS] = "OrpheanBeholderScryDoubt";
184 u_int8_t csalt[BCRYPT_MAXSALT]; 184 u_int8_t csalt[BCRYPT_MAXSALT];
185 u_int32_t cdata[BCRYPT_BLOCKS]; 185 u_int32_t cdata[BCRYPT_BLOCKS];
186 int n;
186 187
187 /* Discard "$" identifier */ 188 /* Discard "$" identifier */
188 salt++; 189 salt++;
@@ -214,9 +215,10 @@ bcrypt(const char *key, const char *salt)
214 return error; 215 return error;
215 216
216 /* Computer power doesn't increase linear, 2^x should be fine */ 217 /* Computer power doesn't increase linear, 2^x should be fine */
217 logr = atoi(salt); 218 n = atoi(salt);
218 if (logr > 31) 219 if (n > 31 || n < 0)
219 return error; 220 return error;
221 logr = (u_int8_t)n;
220 if ((rounds = (u_int32_t) 1 << logr) < BCRYPT_MINROUNDS) 222 if ((rounds = (u_int32_t) 1 << logr) < BCRYPT_MINROUNDS)
221 return error; 223 return error;
222 224