mkpasswd: fix an underflow in the parser for -R

Reported by mahkoh on github:
https://github.com/rfc1036/whois/issues/12
This commit is contained in:
Marco d'Itri 2014-01-19 23:50:07 +01:00
parent d053b2f1f6
commit 366ca9bcbe

View File

@ -179,11 +179,14 @@ int main(int argc, char *argv[])
case 'R':
{
char *p;
rounds = strtol(optarg, &p, 10);
if (p == NULL || *p != '\0' || rounds < 0) {
long r;
r = strtol(optarg, &p, 10);
if (p == NULL || *p != '\0' || r < 0) {
fprintf(stderr, _("Invalid number '%s'.\n"), optarg);
exit(1);
}
rounds = r;
}
break;
case 's':