summaryrefslogtreecommitdiff
path: root/mkpasswd.c
diff options
context:
space:
mode:
authorMarco d'Itri <md@linux.it>2014-01-19 23:50:07 +0100
committerMarco d'Itri <md@linux.it>2014-02-06 01:03:05 +0100
commit366ca9bcbe606c9c4be0bcfe11e1d75d89126be4 (patch)
tree92ee8e54c5b8b34990c42b9ca3c9c615eaf7b6df /mkpasswd.c
parentd053b2f1f66a12516c40384dfffdf4253674871b (diff)
downloadwhois-366ca9bcbe606c9c4be0bcfe11e1d75d89126be4.tar.gz
mkpasswd: fix an underflow in the parser for -R
Reported by mahkoh on github: https://github.com/rfc1036/whois/issues/12
Diffstat (limited to 'mkpasswd.c')
-rw-r--r--mkpasswd.c7
1 files 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':