From 162805f4a30e828c2812cdb793a1587610e15ce1 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 10 Oct 2003 13:49:27 +0000 Subject: Smash all NULs out of headers. svn path=/trunk/; revision=3845 --- transact.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/transact.c b/transact.c index e98be346..cae6b701 100644 --- a/transact.c +++ b/transact.c @@ -428,6 +428,8 @@ int readheaders(int sock, linelen = 0; line[0] = '\0'; do { + char *sp, *tp; + set_timeout(mytimeout); if ((n = SockRead(sock, buf, sizeof(buf)-1)) == -1) { set_timeout(0); @@ -438,6 +440,18 @@ int readheaders(int sock, } set_timeout(0); + /* + * Smash out any medial NULs, they could wreak havoc later on. + * Some network stacks seem to generate these at random, + * always (according to reports) at the beginning of the + * first read. NUls are illegal in RFC822 format. + */ + for (sp = tp = buf; sp < buf + n; sp++) + if (*sp) + *tp++ = *sp; + *tp = '\0'; + n = tp - buf; + remaining -= n; linelen += n; msgblk.msglen += n; -- cgit v1.2.3