Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libcperciva/util/parsenum.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ parsenum_float(const char * s, double min, double max, int trailing)
val = strtod(s, &eptr);
if (eptr == s || (!trailing && (*eptr != '\0')))
errno = EINVAL;
else if (isnan(val))
errno = EINVAL;
else if ((val < min) || (val > max))
errno = ERANGE;
return (val);
Expand Down
13 changes: 13 additions & 0 deletions tests/09-explicit-params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,17 @@ scenario_cmd() {
enc -p 12 "${reference_file}" 2>&1 | \
grep -q "If -p is set, --logN and -r must also be set"
echo $? > "${c_exitfile}"

# NaN is not a numeric value within any bounded resource range.
setup_check "scrypt rejects NaN maxmem fraction"
${c_valgrind_cmd} "${bindir}/scrypt" info -m NaN \
"${scriptdir}/verify-strings/test_scrypt_good.enc" 2>&1 | \
grep -q "Invalid option: -m NaN"
echo $? > "${c_exitfile}"

setup_check "scrypt rejects NaN max time"
${c_valgrind_cmd} "${bindir}/scrypt" info -t NaN \
"${scriptdir}/verify-strings/test_scrypt_good.enc" 2>&1 | \
grep -q "Invalid option: -t NaN"
echo $? > "${c_exitfile}"
}