aboutsummaryrefslogtreecommitdiffstats
path: root/transact.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2003-10-10 13:58:41 +0000
committerEric S. Raymond <esr@thyrsus.com>2003-10-10 13:58:41 +0000
commit9b6bcf25f9a75df373fd5e980d0baec4b8bccedb (patch)
tree37779d63df3b5d7c18ec3bb394aa03d4ba264ac5 /transact.c
parent162805f4a30e828c2812cdb793a1587610e15ce1 (diff)
downloadfetchmail-9b6bcf25f9a75df373fd5e980d0baec4b8bccedb.tar.gz
fetchmail-9b6bcf25f9a75df373fd5e980d0baec4b8bccedb.tar.bz2
fetchmail-9b6bcf25f9a75df373fd5e980d0baec4b8bccedb.zip
Smash out nuls.
svn path=/trunk/; revision=3846
Diffstat (limited to 'transact.c')
-rw-r--r--transact.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/transact.c b/transact.c
index cae6b701..bddce829 100644
--- a/transact.c
+++ b/transact.c
@@ -428,29 +428,32 @@ int readheaders(int sock,
linelen = 0;
line[0] = '\0';
do {
- char *sp, *tp;
+ do {
+ char *sp, *tp;
- set_timeout(mytimeout);
- if ((n = SockRead(sock, buf, sizeof(buf)-1)) == -1) {
+ set_timeout(mytimeout);
+ if ((n = SockRead(sock, buf, sizeof(buf)-1)) == -1) {
+ set_timeout(0);
+ free(line);
+ free(msgblk.headers);
+ msgblk.headers = NULL;
+ return(PS_SOCKET);
+ }
set_timeout(0);
- free(line);
- free(msgblk.headers);
- msgblk.headers = NULL;
- return(PS_SOCKET);
- }
- 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;
+ /*
+ * Smash out any NULs, they could wreak havoc later on.
+ * Some network stacks seem to generate these at random,
+ * especially (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;
+ } while
+ (n == 0);
remaining -= n;
linelen += n;