[balsa/gtk3] Fix long-line POP3 bug reported by Rob Landley.



commit b3270a1b19693ad339c68601fa7eb67b4dc815b7
Author: Pawel Salek <pawsa0 gmail com>
Date:   Mon Oct 22 22:36:31 2012 +0200

    Fix long-line POP3 bug reported by Rob Landley.

 ChangeLog            |    4 ++++
 libbalsa/imap/pop3.c |   12 ++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 14bf404..110f5cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-10-22  Pawel Salek
+
+	* libbalsa/imap/pop3.c: fix long-line POP3 bug reported by Rob Landley.
+
 2012-09-30  Peter Bloomfield
 
 	* src/store-address.c (store_address_add_address),
diff --git a/libbalsa/imap/pop3.c b/libbalsa/imap/pop3.c
index cf5d76c..2387daa 100644
--- a/libbalsa/imap/pop3.c
+++ b/libbalsa/imap/pop3.c
@@ -650,10 +650,14 @@ pop_fetch_message_s(PopHandle *pop, unsigned msgno,
   resp = pop_check_status(pop, err);
   /* do here the fetch */
   if(resp) {
+    /* whether next line will be a continuation line. */
+    gboolean continuation_line = FALSE;
     while( sio_gets(pop->sio, line, sizeof(line)) &&
-           strcmp(line, ".\r\n") ) {
+           (continuation_line || strcmp(line, ".\r\n")) ) {
       char *arg = line[0] == '.' ? line+1 : line;
       unsigned len = strlen(arg);
+      continuation_line = (len >= POP_LINE_LEN-1);
+      printf("Line '%s'\n", line);
       if(pop->filter_cr && len>=2 && arg[len-2] == '\r') 
         arg[(--len)-1] = '\n';
       if(resp) 
@@ -663,6 +667,7 @@ pop_fetch_message_s(PopHandle *pop, unsigned msgno,
           resp = FALSE;
         }
     }
+    printf("LAST Line is '%s'\n", line);
   }
   return resp;
 }
@@ -743,10 +748,13 @@ pop_complete_retr(PopHandle *pop, PopAsyncCb cb, void *arg)
     cb(rc, arg, &err);
   if(resp) { /* same code as in fetch_message() */
     char * str;
+    /* whether next line will be a continuation line. */
+    gboolean continuation_line = FALSE;
     while( (str = sio_gets(pop->sio, line, sizeof(line))) &&
-           strcmp(line, ".\r\n") ) {
+           (continuation_line || strcmp(line, ".\r\n")) ) {
       char *buf = line[0] == '.' ? line+1 : line;
       unsigned len = strlen(buf);
+      continuation_line = (len >= POP_LINE_LEN-1);
       if(pop->filter_cr && len>=2 && buf[len-2] == '\r') 
         buf[(--len)-1] = '\n';
       if(cb) 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]