Browse Source

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
OPENBSD_5_7
tedu 9 years ago
parent
commit
6e172aaf1a
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      src/lib/libc/crypt/cryptutil.c

+ 4
- 2
src/lib/libc/crypt/cryptutil.c View File

@ -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);


Loading…
Cancel
Save