From 47dbfb9dda6a1bace01e6bcd36cc1a3f98f9256b Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Tue, 17 Mar 2015 17:00:16 +0100 Subject: diff_opt_parse(): use convert_i() when handling --abbrev= 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 Signed-off-by: Junio C Hamano --- diff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) -- cgit v1.2.1