From 9b699b1aebb24f4f42b0c8b89a497339fc1e1499 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 4 Nov 1996 22:56:43 +0000 Subject: Insert fseeks to prevent read-write lossage. svn path=/trunk/; revision=485 --- driver.c | 12 ++++++++++-- imap.c | 5 +++++ pop3.c | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/driver.c b/driver.c index 9eee8807..46b2a153 100644 --- a/driver.c +++ b/driver.c @@ -789,6 +789,14 @@ struct query *ctl; /* query control record */ lines++; } + /* + * Required by Standard C and the Linux stdio library, + * which wants a seek between read and write operations on a + * read/write stream. Without this we got weird lossage + * trying to issue delete commands after reading a long message. + */ + fseek(sockfp, 0L, SEEK_CUR); + if (ctl->mda[0]) { /* close the delivery pipe, we'll reopen before next message */ @@ -1118,7 +1126,7 @@ va_dcl { va_end(ap); strcat(buf, "\r\n"); - fputs(buf, sockfp); + fputs(buf, sockfp); fseek(sockfp, 0L, SEEK_CUR); if (outlevel == O_VERBOSE) { @@ -1160,7 +1168,7 @@ va_dcl { va_end(ap); strcat(buf, "\r\n"); - fputs(buf, sockfp); + fputs(buf, sockfp); fseek(sockfp, 0L, SEEK_CUR); if (outlevel == O_VERBOSE) { char *cp; diff --git a/imap.c b/imap.c index 3ff1a57c..0e75524d 100644 --- a/imap.c +++ b/imap.c @@ -133,6 +133,7 @@ int *sizes; else sizes[num - 1] = -1; } + fseek(sockfp, 0L, SEEK_CUR); return(0); } @@ -168,6 +169,7 @@ int *lenp; return(PS_SOCKET); } while (sscanf(buf+2, "%d FETCH (RFC822 {%d}", &num, lenp) != 2); + fseek(sockfp, 0L, SEEK_CUR); if (num != number) return(PS_ERROR); @@ -186,7 +188,10 @@ int number; if (fgets(buf, sizeof(buf), sockfp) == (char *)NULL) return(PS_SOCKET); else + { + fseek(sockfp, 0L, SEEK_CUR); return(0); + } } static int imap_delete(sockfp, ctl, number) diff --git a/pop3.c b/pop3.c index 4e5afe4b..cbe6ac0f 100644 --- a/pop3.c +++ b/pop3.c @@ -182,6 +182,7 @@ int *countp, *newp; if (!uid_in_list(&ctl->oldsaved, id)) (*newp)++; } + fseek(sockfp, 0L, SEEK_CUR); } } } @@ -217,6 +218,7 @@ int *sizes; else sizes[num - 1] = -1; } + fseek(sockfp, 0L, SEEK_CUR); return(0); } -- cgit v1.2.3