summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-03-17 17:00:15 +0100
committerJunio C Hamano <gitster@pobox.com>2015-03-19 11:03:01 -0700
commit546cb854931ed7b8d72dbb204e1abe36cc366bdd (patch)
tree966d8d7a3a7370c35f4e4b9b93c106ae6459b317
parent80c01a5b9d32223d4fc6d0abfe0e4e405dcdbe21 (diff)
downloadgit-546cb854931ed7b8d72dbb204e1abe36cc366bdd.tar.gz
diff_opt_parse(): use convert_i() when handling "-l<num>"
die() with an error message if the argument is not a non-negative integer. This change tightens up parsing: '+' and '-', leading whitespace, and trailing junk are all disallowed now. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--diff.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 4c3734d8a0..8d7362b62d 100644
--- a/diff.c
+++ b/diff.c
@@ -3798,7 +3798,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
else if (!strcmp(arg, "-z"))
options->line_termination = 0;
else if ((argcount = short_opt('l', av, &optarg))) {
- options->rename_limit = strtoul(optarg, NULL, 10);
+ if (convert_i(optarg, 10, &options->rename_limit))
+ die("-l requires a non-negative integer argument");
return argcount;
}
else if ((argcount = short_opt('S', av, &optarg))) {