diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2003-10-10 13:49:27 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2003-10-10 13:49:27 +0000 |
commit | 162805f4a30e828c2812cdb793a1587610e15ce1 (patch) | |
tree | ac8dd7c3347b904903037ba8fbd7870eca9238be /transact.c | |
parent | 237e720198ab715d96cb75b86ade41431f64e8c4 (diff) | |
download | fetchmail-162805f4a30e828c2812cdb793a1587610e15ce1.tar.gz fetchmail-162805f4a30e828c2812cdb793a1587610e15ce1.tar.bz2 fetchmail-162805f4a30e828c2812cdb793a1587610e15ce1.zip |
Smash all NULs out of headers.
svn path=/trunk/; revision=3845
Diffstat (limited to 'transact.c')
-rw-r--r-- | transact.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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; |