summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2016-03-12 13:35:35 +0100
committerJunio C Hamano <gitster@pobox.com>2016-04-06 12:58:35 -0700
commit048e99da2e1e510566e95b339632f98031ee59bf (patch)
tree1cf6668a2d53def31ea57208a74207730b423be5
parent765428699a5381f113d19974720bc91b5bfeaf1d (diff)
downloadgit-wt/sign-off-with-cruft.tar.gz
sequencer.c: fix detection of duplicate s-o-bwt/sign-off-with-cruft
Commit bab4d10 ("sequencer.c: teach append_signoff how to detect duplicate s-o-b") changed the method used to detect duplicate s-o-b, but it introduced a regression for a case where some non-compliant information are present in the footer. In maintenance branches, it's very common to add some elements after the signed-off and to add your s-o-b after. This is used a lot in the stable kernel series, for example this commit backported from 3.2 to 2.6.32 : ALSA: usb-audio: avoid freeing umidi object twice commit 07d86ca93db7e5cdf4743564d98292042ec21af7 upstream. The 'umidi' object will be free'd on the error path by snd_usbmidi_free() when tearing down the rawmidi interface. So we shouldn't try to free it in snd_usbmidi_create() after having registered the rawmidi interface. Found by KASAN. Signed-off-by: Andrey Konovalov <andreyknvl@gmail.com> Acked-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> [wt: file is sound/midi/usbmidi.c in 2.6.32] Signed-off-by: Willy Tarreau <w@1wt.eu> Prior to the commit above, a cherry-pick -s would not append an extra s-o-b. After this commit, a new line and a second s-o-b are added, making the footer look like this : Signed-off-by: Andrey Konovalov <andreyknvl@gmail.com> Acked-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> [wt: file is sound/midi/usbmidi.c in 2.6.32] Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Willy Tarreau <w@1wt.eu> This patch improves the parsing of the footer by considering the presence of a valid rfc2822 line after possibly non-conformant lines. Indeed, if someone added an s-o-b or CC after some stuff, this line must properly be considered as part of the footer and not of the body. Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sequencer.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sequencer.c b/sequencer.c
index c4f4b7d571..52a05cef57 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -59,6 +59,8 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
int len = sb->len - ignore_footer;
const char *buf = sb->buf;
int found_sob = 0;
+ int found_valid = 0;
+ int found_other = 0;
/* footer must end with newline */
if (!len || buf[len - 1] != '\n')
@@ -91,15 +93,18 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
if (found_rfc2822 && sob &&
!strncmp(buf + i, sob->buf, sob->len))
found_sob = k;
-
- if (!(found_rfc2822 ||
- is_cherry_picked_from_line(buf + i, k - i - 1)))
- return 0;
+ else if (found_rfc2822 ||
+ is_cherry_picked_from_line(buf + i, k - i - 1))
+ found_valid = k;
+ else
+ found_other = k;
}
if (found_sob == i)
return 3;
- if (found_sob)
+ if (found_sob > found_other)
return 2;
+ if (found_other > found_valid)
+ return 0;
return 1;
}