diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2015-03-17 17:00:16 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-03-19 11:03:01 -0700 |
commit | 47dbfb9dda6a1bace01e6bcd36cc1a3f98f9256b (patch) | |
tree | 401c013048462d555ebb6348eab2a108050903de | |
parent | 546cb854931ed7b8d72dbb204e1abe36cc366bdd (diff) | |
download | git-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.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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) |