Merge branch 'ab/fix-strategy-opts-parsing'
The code to parse "git rebase -X<opt>" was not prepared to see an unparsable option string, which has been corrected. * ab/fix-strategy-opts-parsing: sequencer.c: fix overflow & segfault in parse_strategy_opts()maint
commit
fc1a4ce043
|
@ -2919,13 +2919,18 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
|
|||
void parse_strategy_opts(struct replay_opts *opts, char *raw_opts)
|
||||
{
|
||||
int i;
|
||||
int count;
|
||||
char *strategy_opts_string = raw_opts;
|
||||
|
||||
if (*strategy_opts_string == ' ')
|
||||
strategy_opts_string++;
|
||||
|
||||
opts->xopts_nr = split_cmdline(strategy_opts_string,
|
||||
(const char ***)&opts->xopts);
|
||||
count = split_cmdline(strategy_opts_string,
|
||||
(const char ***)&opts->xopts);
|
||||
if (count < 0)
|
||||
die(_("could not split '%s': %s"), strategy_opts_string,
|
||||
split_cmdline_strerror(count));
|
||||
opts->xopts_nr = count;
|
||||
for (i = 0; i < opts->xopts_nr; i++) {
|
||||
const char *arg = opts->xopts[i];
|
||||
|
||||
|
|
|
@ -40,6 +40,24 @@ test_expect_success 'setup' '
|
|||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'bad -X <strategy-option> arguments: unclosed quote' '
|
||||
cat >expect <<-\EOF &&
|
||||
fatal: could not split '\''--bad'\'': unclosed quote
|
||||
EOF
|
||||
test_expect_code 128 git rebase -X"bad argument\"" side main >out 2>actual &&
|
||||
test_must_be_empty out &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'bad -X <strategy-option> arguments: bad escape' '
|
||||
cat >expect <<-\EOF &&
|
||||
fatal: could not split '\''--bad'\'': cmdline ends with \
|
||||
EOF
|
||||
test_expect_code 128 git rebase -X"bad escape \\" side main >out 2>actual &&
|
||||
test_must_be_empty out &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success '--ignore-whitespace works with apply backend' '
|
||||
test_must_fail git rebase --apply main side &&
|
||||
git rebase --abort &&
|
||||
|
|
Loading…
Reference in New Issue