Git fork

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()

+25 -2
+7 -2
sequencer.c
··· 2919 2919 void parse_strategy_opts(struct replay_opts *opts, char *raw_opts) 2920 2920 { 2921 2921 int i; 2922 + int count; 2922 2923 char *strategy_opts_string = raw_opts; 2923 2924 2924 2925 if (*strategy_opts_string == ' ') 2925 2926 strategy_opts_string++; 2926 2927 2927 - opts->xopts_nr = split_cmdline(strategy_opts_string, 2928 - (const char ***)&opts->xopts); 2928 + count = split_cmdline(strategy_opts_string, 2929 + (const char ***)&opts->xopts); 2930 + if (count < 0) 2931 + die(_("could not split '%s': %s"), strategy_opts_string, 2932 + split_cmdline_strerror(count)); 2933 + opts->xopts_nr = count; 2929 2934 for (i = 0; i < opts->xopts_nr; i++) { 2930 2935 const char *arg = opts->xopts[i]; 2931 2936
+18
t/t3436-rebase-more-options.sh
··· 40 40 EOF 41 41 ' 42 42 43 + test_expect_success 'bad -X <strategy-option> arguments: unclosed quote' ' 44 + cat >expect <<-\EOF && 45 + fatal: could not split '\''--bad'\'': unclosed quote 46 + EOF 47 + test_expect_code 128 git rebase -X"bad argument\"" side main >out 2>actual && 48 + test_must_be_empty out && 49 + test_cmp expect actual 50 + ' 51 + 52 + test_expect_success 'bad -X <strategy-option> arguments: bad escape' ' 53 + cat >expect <<-\EOF && 54 + fatal: could not split '\''--bad'\'': cmdline ends with \ 55 + EOF 56 + test_expect_code 128 git rebase -X"bad escape \\" side main >out 2>actual && 57 + test_must_be_empty out && 58 + test_cmp expect actual 59 + ' 60 + 43 61 test_expect_success '--ignore-whitespace works with apply backend' ' 44 62 test_must_fail git rebase --apply main side && 45 63 git rebase --abort &&