summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-11-28 13:42:46 -0600
committerJunio C Hamano <gitster@pobox.com>2010-12-01 13:26:52 -0800
commita9ff277e583782346181f431784e48046b0dfaa9 (patch)
tree01a2fc07ee976a9f9cbd32d8c5fec906ffc19009 /fast-import.c
parent7d43de925b2771d295d8fc4341b7bd544e2a74fa (diff)
downloadgit-a9ff277e583782346181f431784e48046b0dfaa9.tar.gz
fast-import: stricter parsing of integer options
Check the result from strtoul to avoid accepting arguments like --depth=-1 and --active-branches=foo,bar,baz. Requested-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fast-import.c b/fast-import.c
index 77549ebd6f..4bd9bf7d08 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2746,16 +2746,25 @@ static void option_date_format(const char *fmt)
die("unknown --date-format argument %s", fmt);
}
+static unsigned long ulong_arg(const char *option, const char *arg)
+{
+ char *endptr;
+ unsigned long rv = strtoul(arg, &endptr, 0);
+ if (strchr(arg, '-') || endptr == arg || *endptr)
+ die("%s: argument must be a non-negative integer", option);
+ return rv;
+}
+
static void option_depth(const char *depth)
{
- max_depth = strtoul(depth, NULL, 0);
+ max_depth = ulong_arg("--depth", depth);
if (max_depth > MAX_DEPTH)
die("--depth cannot exceed %u", MAX_DEPTH);
}
static void option_active_branches(const char *branches)
{
- max_active_branches = strtoul(branches, NULL, 0);
+ max_active_branches = ulong_arg("--active-branches", branches);
}
static void option_export_marks(const char *marks)