Skip to content

Commit ad78486

Browse files
committed
net_imap: Tolerate header lines longer than 1,000.
If a header line is longer than 1,000 characters, this would previously cause parsing to fail. The X-Xfinity-VAAS header has been observed in the while with 1,263 characters all on a single line. Even though headers like this Xfinity header violate the RFC, we should be able to tolerate them and not abort header parsing entirely; increase the buffer size by 50%, which should be sufficient for edge cases like this. LBBS-147 #close
1 parent 9e3725a commit ad78486

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

nets/net_imap/imap_server_fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static int send_filtered_headers(struct imap_session *imap, struct fetch_body_re
266266
size_t headersbuflen = sizeof(headersbuf);
267267
char *buf = headersbuf;
268268
size_t len = headersbuflen;
269-
char linebuf[1001];
269+
char linebuf[1500]; /* Even though header lines should not be longer than ~1,000 chars, sometimes they are longer in the wild and we should be able to handle them */
270270
char listbuf[4096];
271271
int inside_match = filter ? 0 : 1;
272272
size_t headerslen;
@@ -327,7 +327,7 @@ static int send_filtered_headers(struct imap_session *imap, struct fetch_body_re
327327
safe_strncpy(headername + 1, linebuf, sizeof(headername) - 1);
328328
tmp = strchr(headername + 1, ':');
329329
if (!tmp) {
330-
bbs_warning("Unexpected end of headers: %s\n", linebuf);
330+
bbs_warning("Unexpected end of headers in %s: %s\n", fullname, linebuf);
331331
break;
332332
}
333333
/* Since safe_strncpy will always null terminate,

0 commit comments

Comments
 (0)