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, ']');
|
pos = strchr(subject->buf + at, ']');
|
||||||
if (!pos)
|
if (!pos)
|
||||||
break;
|
break;
|
||||||
remove = pos - subject->buf + at + 1;
|
remove = pos - (subject->buf + at) + 1;
|
||||||
if (!mi->keep_non_patch_brackets_in_subject ||
|
if (!mi->keep_non_patch_brackets_in_subject ||
|
||||||
(7 <= remove &&
|
(7 <= remove &&
|
||||||
memmem(subject->buf + at, remove, "PATCH", 5)))
|
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 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" |
|
subj="$(echo "Subject: [other] [PATCH] message" |
|
||||||
git mailinfo -b /dev/null /dev/null)" &&
|
git mailinfo -b /dev/null /dev/null)" &&
|
||||||
test z"$subj" = z"Subject: [other] message"
|
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" |
|
subj="$(echo "Subject: [PATCH] [other] [PATCH] message" |
|
||||||
git mailinfo -b /dev/null /dev/null)" &&
|
git mailinfo -b /dev/null /dev/null)" &&
|
||||||
test z"$subj" = z"Subject: [other] message"
|
test z"$subj" = z"Subject: [other] message"
|
||||||
|
Loading…
Reference in New Issue
Block a user