summaryrefslogtreecommitdiff
path: root/mailinfo.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-09-23 20:04:40 +0200
committerJunio C Hamano <gitster@pobox.com>2017-09-24 10:29:19 +0900
commitc8cf423eab6f260128859dfec991c36c54a3551c (patch)
tree94122cc0c602f5a6159d3ec3f9734f1733fa9542 /mailinfo.c
parent0bfff8146f8c055fd95af4567286929ba8216fa7 (diff)
downloadgit-c8cf423eab6f260128859dfec991c36c54a3551c.tar.gz
mailinfo: don't decode invalid =XY quoted-printable sequencesrs/mailinfo-qp-decode-fix
Decode =XY in quoted-printable segments only if X and Y are hexadecimal digits, otherwise just copy them. That's at least better than interpreting negative results from hexval() as a character. Reported-by: Jeff King <peff@peff.net> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mailinfo.c')
-rw-r--r--mailinfo.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/mailinfo.c b/mailinfo.c
index b4118a0275..5a597ef89c 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -367,11 +367,16 @@ static struct strbuf *decode_q_segment(const struct strbuf *q_seg, int rfc2047)
while ((c = *in++) != 0) {
if (c == '=') {
- int d = *in++;
+ int ch, d = *in;
if (d == '\n' || !d)
break; /* drop trailing newline */
- strbuf_addch(out, (hexval(d) << 4) | hexval(*in++));
- continue;
+ ch = hex2chr(in);
+ if (ch >= 0) {
+ strbuf_addch(out, ch);
+ in += 2;
+ continue;
+ }
+ /* garbage -- fall through */
}
if (rfc2047 && c == '_') /* rfc2047 4.2 (2) */
c = 0x20;