summaryrefslogtreecommitdiffstats
path: root/lib/libc/crypt/cryptutil.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2015-02-24 19:19:32 +0000
committertedu <tedu@openbsd.org>2015-02-24 19:19:32 +0000
commit3d7603d5457cc6c8b1932aad8c6480179f1bdc3a (patch)
treec834a2487a125e5f3f5be0f2ca00dfa21bc721b0 /lib/libc/crypt/cryptutil.c
parentincrease prefbuf size so that 'encrypt -b 000000000000000000000012' works. (diff)
downloadwireguard-openbsd-3d7603d5457cc6c8b1932aad8c6480179f1bdc3a.tar.xz
wireguard-openbsd-3d7603d5457cc6c8b1932aad8c6480179f1bdc3a.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
Diffstat (limited to 'lib/libc/crypt/cryptutil.c')
-rw-r--r--lib/libc/crypt/cryptutil.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/crypt/cryptutil.c b/lib/libc/crypt/cryptutil.c
index c3ba08f9963..75c48c52f7e 100644
--- a/lib/libc/crypt/cryptutil.c
+++ b/lib/libc/crypt/cryptutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cryptutil.c,v 1.8 2015/01/15 17:32:43 chl Exp $ */
+/* $OpenBSD: cryptutil.c,v 1.9 2015/02/24 19:19:32 tedu Exp $ */
/*
* Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
*
@@ -69,8 +69,10 @@ crypt_newhash(const char *pass, const char *pref, char *hash, size_t hashlen)
rounds = bcrypt_autorounds();
} else {
rounds = strtonum(pref + 9, 4, 31, &errstr);
- if (errstr)
+ if (errstr) {
+ errno = EINVAL;
goto err;
+ }
}
rv = bcrypt_newhash(pass, rounds, hash, hashlen);