aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-04-09 17:06:33 +0000
committerNIIBE Yutaka <[email protected]>2015-04-15 07:07:56 +0000
commitde7f7b98dfeb30675369d0bedc6d639314193e96 (patch)
tree3f306fa58bd4c0da20d05241976e341b0e4e4cf1
parentagent: Fix length test in sshcontrol parser. (diff)
downloadgnupg-de7f7b98dfeb30675369d0bedc6d639314193e96.tar.gz
gnupg-de7f7b98dfeb30675369d0bedc6d639314193e96.zip
gpgparsemail: Fix case of zero length continuation lines.
* tools/rfc822parse.c (parse_field): Loop after continuation line. -- Using header lines like Name:[lf] [space][lf] [lf] resulted in running into the "(s2 = strchr (delimiters2, *s)" branch and inserting a new token for the empty continuation line. This also led to one byte read after the string which is what Hanno figured. The new code should handle empty continuation lines correct. Reported-by: Hanno Böck Signed-off-by: Werner Koch <[email protected]> (backported from 2.1 commit 3fbeba64a8bfb2b673230c124a3d616b6568fd2f)
-rw-r--r--tools/rfc822parse.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/rfc822parse.c b/tools/rfc822parse.c
index 8fbe3c283..7b86ea945 100644
--- a/tools/rfc822parse.c
+++ b/tools/rfc822parse.c
@@ -808,10 +808,12 @@ parse_field (HDR_LINE hdr)
s++; /* Move over the colon. */
for (;;)
{
- if (!*s)
+ while (!*s)
{
if (!hdr->next || !hdr->next->cont)
- break;
+ return tok; /* Ready. */
+
+ /* Next item is a header continuation line. */
hdr = hdr->next;
s = hdr->line;
}
@@ -824,10 +826,11 @@ parse_field (HDR_LINE hdr)
invalid = 0;
for (s++;; s++)
{
- if (!*s)
+ while (!*s)
{
if (!hdr->next || !hdr->next->cont)
break;
+ /* Next item is a header continuation line. */
hdr = hdr->next;
s = hdr->line;
}
@@ -880,6 +883,7 @@ parse_field (HDR_LINE hdr)
if (*s2 || !hdr->next || !hdr->next->cont)
break;
+ /* Next item is a header continuation line. */
hdr = hdr->next;
s = hdr->line;
}
@@ -931,8 +935,7 @@ parse_field (HDR_LINE hdr)
s++;
}
}
-
- return tok;
+ /*NOTREACHED*/
failure:
{