From 366ca9bcbe606c9c4be0bcfe11e1d75d89126be4 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sun, 19 Jan 2014 23:50:07 +0100 Subject: [PATCH] mkpasswd: fix an underflow in the parser for -R Reported by mahkoh on github: https://github.com/rfc1036/whois/issues/12 --- mkpasswd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mkpasswd.c b/mkpasswd.c index 5820f32..d7c31a1 100644 --- a/mkpasswd.c +++ b/mkpasswd.c @@ -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':