mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
Merge branch 'cb/bisect-helper-parser-fix'
The code to parse "git bisect start" command line was lax in validating the arguments. * cb/bisect-helper-parser-fix: bisect--helper: avoid segfault with bad syntax in `start --term-*`
This commit is contained in:
commit
63e50b8678
|
@ -455,9 +455,12 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
|
||||||
no_checkout = 1;
|
no_checkout = 1;
|
||||||
} else if (!strcmp(arg, "--term-good") ||
|
} else if (!strcmp(arg, "--term-good") ||
|
||||||
!strcmp(arg, "--term-old")) {
|
!strcmp(arg, "--term-old")) {
|
||||||
|
i++;
|
||||||
|
if (argc <= i)
|
||||||
|
return error(_("'' is not a valid term"));
|
||||||
must_write_terms = 1;
|
must_write_terms = 1;
|
||||||
free((void *) terms->term_good);
|
free((void *) terms->term_good);
|
||||||
terms->term_good = xstrdup(argv[++i]);
|
terms->term_good = xstrdup(argv[i]);
|
||||||
} else if (skip_prefix(arg, "--term-good=", &arg) ||
|
} else if (skip_prefix(arg, "--term-good=", &arg) ||
|
||||||
skip_prefix(arg, "--term-old=", &arg)) {
|
skip_prefix(arg, "--term-old=", &arg)) {
|
||||||
must_write_terms = 1;
|
must_write_terms = 1;
|
||||||
|
@ -465,16 +468,18 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
|
||||||
terms->term_good = xstrdup(arg);
|
terms->term_good = xstrdup(arg);
|
||||||
} else if (!strcmp(arg, "--term-bad") ||
|
} else if (!strcmp(arg, "--term-bad") ||
|
||||||
!strcmp(arg, "--term-new")) {
|
!strcmp(arg, "--term-new")) {
|
||||||
|
i++;
|
||||||
|
if (argc <= i)
|
||||||
|
return error(_("'' is not a valid term"));
|
||||||
must_write_terms = 1;
|
must_write_terms = 1;
|
||||||
free((void *) terms->term_bad);
|
free((void *) terms->term_bad);
|
||||||
terms->term_bad = xstrdup(argv[++i]);
|
terms->term_bad = xstrdup(argv[i]);
|
||||||
} else if (skip_prefix(arg, "--term-bad=", &arg) ||
|
} else if (skip_prefix(arg, "--term-bad=", &arg) ||
|
||||||
skip_prefix(arg, "--term-new=", &arg)) {
|
skip_prefix(arg, "--term-new=", &arg)) {
|
||||||
must_write_terms = 1;
|
must_write_terms = 1;
|
||||||
free((void *) terms->term_bad);
|
free((void *) terms->term_bad);
|
||||||
terms->term_bad = xstrdup(arg);
|
terms->term_bad = xstrdup(arg);
|
||||||
} else if (starts_with(arg, "--") &&
|
} else if (starts_with(arg, "--")) {
|
||||||
!one_of(arg, "--term-good", "--term-bad", NULL)) {
|
|
||||||
return error(_("unrecognized option: '%s'"), arg);
|
return error(_("unrecognized option: '%s'"), arg);
|
||||||
} else {
|
} else {
|
||||||
char *commit_id = xstrfmt("%s^{commit}", arg);
|
char *commit_id = xstrfmt("%s^{commit}", arg);
|
||||||
|
|
|
@ -866,7 +866,9 @@ test_expect_success 'bisect cannot mix terms' '
|
||||||
|
|
||||||
test_expect_success 'bisect terms rejects invalid terms' '
|
test_expect_success 'bisect terms rejects invalid terms' '
|
||||||
git bisect reset &&
|
git bisect reset &&
|
||||||
|
test_must_fail git bisect start --term-good &&
|
||||||
test_must_fail git bisect start --term-good invalid..term &&
|
test_must_fail git bisect start --term-good invalid..term &&
|
||||||
|
test_must_fail git bisect start --term-bad &&
|
||||||
test_must_fail git bisect terms --term-bad invalid..term &&
|
test_must_fail git bisect terms --term-bad invalid..term &&
|
||||||
test_must_fail git bisect terms --term-good bad &&
|
test_must_fail git bisect terms --term-good bad &&
|
||||||
test_must_fail git bisect terms --term-good old &&
|
test_must_fail git bisect terms --term-good old &&
|
||||||
|
|
Loading…
Reference in a new issue