Fix 'From ' line parsing bug.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1588 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1997-04-18 00:36:07 +00:00
parent 5c5947ce69
commit bab8258a2d
2 changed files with 17 additions and 9 deletions

View File

@@ -136,15 +136,19 @@ pop_send(POP *p)
return (pop_msg (p,POP_FAILURE,"SIGHUP or SIGPIPE flagged")); return (pop_msg (p,POP_FAILURE,"SIGHUP or SIGPIPE flagged"));
} }
/* Send the message body */ /* Send the message body */
{
int blank_line = 0;
while (fgets(buffer,MAXMSGLINELEN,p->drop)) { while (fgets(buffer,MAXMSGLINELEN,p->drop)) {
/* Look for the start of the next message */ /* Look for the start of the next message */
if (strncmp(buffer,"From ",5) == 0) break; if (blank_line && strncmp(buffer,"From ",5) == 0) break;
blank_line = (strncmp(buffer, "\n", 1) == 0);
/* Decrement the lines sent (for a TOP command) */ /* Decrement the lines sent (for a TOP command) */
if (msg_lines >= 0 && msg_lines-- == 0) break; if (msg_lines >= 0 && msg_lines-- == 0) break;
pop_sendline(p,buffer); pop_sendline(p,buffer);
if (hangup) if (hangup)
return (pop_msg (p,POP_FAILURE,"SIGHUP or SIGPIPE flagged")); return (pop_msg (p,POP_FAILURE,"SIGHUP or SIGPIPE flagged"));
} }
}
/* "." signals the end of a multi-line transmission */ /* "." signals the end of a multi-line transmission */
fputs(".\r\n",p->output); fputs(".\r\n",p->output);
fflush(p->output); fflush(p->output);

View File

@@ -33,6 +33,8 @@ pop_updt (POP *p)
long offset; /* New mail offset */ long offset; /* New mail offset */
int blank_line;
#ifdef DEBUG #ifdef DEBUG
if (p->debug) { if (p->debug) {
pop_log(p,POP_DEBUG,"Performing maildrop update..."); pop_log(p,POP_DEBUG,"Performing maildrop update...");
@@ -120,6 +122,7 @@ pop_updt (POP *p)
if(p->debug) if(p->debug)
pop_log(p,POP_DEBUG,"Copying message %d.",mp->number); pop_log(p,POP_DEBUG,"Copying message %d.",mp->number);
#endif /* DEBUG */ #endif /* DEBUG */
blank_line = 1;
for(status_written = doing_body = 0 ; for(status_written = doing_body = 0 ;
fgets(buffer,MAXMSGLINELEN,p->drop);) { fgets(buffer,MAXMSGLINELEN,p->drop);) {
@@ -150,8 +153,9 @@ pop_updt (POP *p)
fputs (buffer, md); fputs (buffer, md);
} }
else { /* Body */ else { /* Body */
if (strncmp(buffer,"From ",5) == 0) break; if (blank_line && strncmp(buffer,"From ",5) == 0) break;
fputs (buffer, md); fputs (buffer, md);
blank_line = (*buffer == '\n');
} }
} }
} }