summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortedu <>2015-02-24 19:19:32 +0000
committertedu <>2015-02-24 19:19:32 +0000
commitc26938f193a6b5aa045558e4f3b17074d78823a0 (patch)
tree698aa4f0becbb1736c300ecd068b9d0662ed1e61
parent9cb1a51933a1847042ee88e16d560485f682bcad (diff)
downloadopenbsd-c26938f193a6b5aa045558e4f3b17074d78823a0.tar.gz
openbsd-c26938f193a6b5aa045558e4f3b17074d78823a0.tar.bz2
openbsd-c26938f193a6b5aa045558e4f3b17074d78823a0.zip
Set errno to EINVAL, instead of letting ERANGE escape out.
Printing strerror() in that case will say result too large, even if rounds is actually too small. invalid is less specific, but less incorrect. ok millert
-rw-r--r--src/lib/libc/crypt/cryptutil.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/libc/crypt/cryptutil.c b/src/lib/libc/crypt/cryptutil.c
index c3ba08f996..75c48c52f7 100644
--- a/src/lib/libc/crypt/cryptutil.c
+++ b/src/lib/libc/crypt/cryptutil.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cryptutil.c,v 1.8 2015/01/15 17:32:43 chl Exp $ */ 1/* $OpenBSD: cryptutil.c,v 1.9 2015/02/24 19:19:32 tedu Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3 * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4 * 4 *
@@ -69,8 +69,10 @@ crypt_newhash(const char *pass, const char *pref, char *hash, size_t hashlen)
69 rounds = bcrypt_autorounds(); 69 rounds = bcrypt_autorounds();
70 } else { 70 } else {
71 rounds = strtonum(pref + 9, 4, 31, &errstr); 71 rounds = strtonum(pref + 9, 4, 31, &errstr);
72 if (errstr) 72 if (errstr) {
73 errno = EINVAL;
73 goto err; 74 goto err;
75 }
74 } 76 }
75 rv = bcrypt_newhash(pass, rounds, hash, hashlen); 77 rv = bcrypt_newhash(pass, rounds, hash, hashlen);
76 78