fast-import: fix read of uninitialized argv memory
authorJeff King <redacted>
Wed, 18 Jun 2014 19:46:15 +0000 (15:46 -0400)
committerJunio C Hamano <redacted>
Fri, 20 Jun 2014 17:44:44 +0000 (10:44 -0700)
commitff45c0d4a316d620d118ec628dd8e78597a23321
treef1d6e5018ef25b0b0b3f79fa0cbbf7508a0a3bf3
parentce2ecf29241ca90655da37918044cbbaff48a2bd
fast-import: fix read of uninitialized argv memory

Fast-import shares code between its command-line parser and
the "option" command. To do so, it strips the "--" from any
command-line options and passes them to the option parser.
However, it does not confirm that the option even begins
with "--" before blindly passing "arg + 2".

It does confirm that the option starts with "-", so the only
affected case was:

  git fast-import -

which would read uninitialized memory after the argument. We
can fix it by using skip_prefix and checking the result. As
a bonus, this gets rid of some magic numbers.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
fast-import.c
git clone https://git.99rst.org/PROJECT