updated the crlf filter:
authorJeffrey Stedfast <fejj@src.gnome.org>
Mon, 12 Jun 2000 23:20:16 +0000 (23:20 +0000)
committerJeffrey Stedfast <fejj@src.gnome.org>
Mon, 12 Jun 2000 23:20:16 +0000 (23:20 +0000)
encoder: allocate more memory (3 * len instead of 2 * len)

decoder: prevent p from pointing beyond the end of the buffer

camel/camel-mime-filter-crlf.c

index 5cc409d..8e3ff21 100644 (file)
@@ -76,7 +76,7 @@ filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
        do_dots = crlf->mode == CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS;
 
        if (crlf->direction == CAMEL_MIME_FILTER_CRLF_ENCODE) {
-               camel_mime_filter_set_size (f, 2 * len, FALSE);
+               camel_mime_filter_set_size (f, 3 * len, FALSE);
 
                p = in;
                q = f->outbuf;
@@ -96,29 +96,29 @@ filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
                while (p < in + len) {
                        if (*p == '\r') {
                                crlf->saw_cr = TRUE;
-                               p++;
                        } else {
                                if (crlf->saw_cr) {
                                        if (*p != '\n')
                                                *q++ = '\r';
                                        crlf->saw_cr = FALSE;
                                }
-                               *q++ = *p++;
+                               *q++ = *p;
                        }
 
                        if (do_dots) {
                                if (*p == '.' && *(p - 1) == '\n') {
                                        crlf->saw_dot = TRUE;
-                                       p++;
                                } else {
                                        if (crlf->saw_dot) {
                                                if (*p == '.')
                                                        p++;
                                                crlf->saw_dot = FALSE;
                                        }
-                                       *q++ = *p++;
+                                       *q++ = *p;
                                }
                        }
+
+                       p++;
                }
        }