mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
Merge branch 'pw/mailinfo-b-fix' into maint-2.38
Fix a logic in "mailinfo -b" that miscomputed the length of a substring, which lead to an out-of-bounds access. * pw/mailinfo-b-fix: mailinfo -b: fix an out of bounds access
This commit is contained in:
commit
3694b3844e
|
@ -317,7 +317,7 @@ static void cleanup_subject(struct mailinfo *mi, struct strbuf *subject)
|
|||
pos = strchr(subject->buf + at, ']');
|
||||
if (!pos)
|
||||
break;
|
||||
remove = pos - subject->buf + at + 1;
|
||||
remove = pos - (subject->buf + at) + 1;
|
||||
if (!mi->keep_non_patch_brackets_in_subject ||
|
||||
(7 <= remove &&
|
||||
memmem(subject->buf + at, remove, "PATCH", 5)))
|
||||
|
|
|
@ -201,13 +201,13 @@ test_expect_success 'mailinfo -b double [PATCH]' '
|
|||
test z"$subj" = z"Subject: message"
|
||||
'
|
||||
|
||||
test_expect_failure 'mailinfo -b trailing [PATCH]' '
|
||||
test_expect_success 'mailinfo -b trailing [PATCH]' '
|
||||
subj="$(echo "Subject: [other] [PATCH] message" |
|
||||
git mailinfo -b /dev/null /dev/null)" &&
|
||||
test z"$subj" = z"Subject: [other] message"
|
||||
'
|
||||
|
||||
test_expect_failure 'mailinfo -b separated double [PATCH]' '
|
||||
test_expect_success 'mailinfo -b separated double [PATCH]' '
|
||||
subj="$(echo "Subject: [PATCH] [other] [PATCH] message" |
|
||||
git mailinfo -b /dev/null /dev/null)" &&
|
||||
test z"$subj" = z"Subject: [other] message"
|
||||
|
|
Loading…
Reference in a new issue