summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-03-17 17:00:16 +0100
committerJunio C Hamano <gitster@pobox.com>2015-03-19 11:03:01 -0700
commit47dbfb9dda6a1bace01e6bcd36cc1a3f98f9256b (patch)
tree401c013048462d555ebb6348eab2a108050903de
parent546cb854931ed7b8d72dbb204e1abe36cc366bdd (diff)
downloadgit-mh/numparse.tar.gz
diff_opt_parse(): use convert_i() when handling --abbrev=<num>mh/numparse
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 8d7362b62d..8818d09e6c 100644
--- a/diff.c
+++ b/diff.c
@@ -3829,7 +3829,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
else if (!strcmp(arg, "--abbrev"))
options->abbrev = DEFAULT_ABBREV;
else if (skip_prefix(arg, "--abbrev=", &arg)) {
- options->abbrev = strtoul(arg, NULL, 10);
+ if (convert_i(arg, 10, &options->abbrev))
+ die("--abbrev requires an integer argument");
if (options->abbrev < MINIMUM_ABBREV)
options->abbrev = MINIMUM_ABBREV;
else if (40 < options->abbrev)