When extracting a literal string, capture up until the end of the last
authorJeffrey Stedfast <fejj@helixcode.com>
Fri, 17 Nov 2000 08:11:29 +0000 (08:11 +0000)
committerJeffrey Stedfast <fejj@src.gnome.org>
Fri, 17 Nov 2000 08:11:29 +0000 (08:11 +0000)
2000-11-17  Jeffrey Stedfast  <fejj@helixcode.com>

* providers/imap/camel-imap-utils.c (imap_parse_nstring): When
extracting a literal string, capture up until the end of the last
line - this we we don't lose any data if the byte count is off.

* providers/imap/camel-imap-command.c (imap_read_untagged): Use
the byte-read count to decrement the number of bytes left to read
rather than using strlen. Not only does this protect against a DoS
(embedded NUL chars in the literal string would make strlen
inaccurate) but it also improves performace a little.

* camel-remote-store.c (remote_recv_line): *Sigh* Return the
number of bytes read on success rather than 0. Also don't use
camel_stream_buffer_read_line since we can't get an accurate octet
count.

camel/ChangeLog
camel/providers/imap/camel-imap-utils.c

index 38ec264..734bbbe 100644 (file)
@@ -1,5 +1,9 @@
 2000-11-17  Jeffrey Stedfast  <fejj@helixcode.com>
 
+       * providers/imap/camel-imap-utils.c (imap_parse_nstring): When
+       extracting a literal string, capture up until the end of the last
+       line - this we we don't lose any data if the byte count is off.
+
        * providers/imap/camel-imap-command.c (imap_read_untagged): Use
        the byte-read count to decrement the number of bytes left to read
        rather than using strlen. Not only does this protect against a DoS
index b38024e..0677c63 100644 (file)
@@ -637,6 +637,10 @@ imap_parse_nstring (char **str_p, int *len)
                        *str_p = NULL;
                        return NULL;
                }
+               
+               /* capture up until the end of the line - byte count may be a little off */
+               for ( ; *(str + *len) != '\n'; (*len)++);
+               
                out = g_strndup (str, *len);
                *str_p = str + *len;
                return out;