]> code.citadel.org Git - citadel.git/commitdiff
Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorArt Cancro <ajc@citadel.org>
Wed, 8 Dec 2010 14:04:52 +0000 (09:04 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 8 Dec 2010 14:04:52 +0000 (09:04 -0500)
libcitadel/lib/mime_parser.c
libcitadel/tests/mimeparser_test.c

index 3b10588b7a3fc2c0413fc89790bca71f0e762690..7e4cbfb222ba3df3f447dfcd6474d6e7295caee8 100644 (file)
@@ -536,8 +536,13 @@ static char *FindNextContent(char *ptr,
                        if (pptr < content_end)
                                ptr = pptr;
                }
+               
+
                next_boundary = NULL;
-               for (srch=ptr; srch<content_end; ++srch) {
+               for (srch=ptr; 
+                    (srch != NULL) && (srch < content_end); 
+                    srch = memchr(srch, '-',  content_end - srch)) 
+               {
                        if (!memcmp(srch, 
                                    m->b[startary].Key, 
                                    m->b[startary].len)) 
@@ -545,6 +550,8 @@ static char *FindNextContent(char *ptr,
                                next_boundary = srch;
                                srch = content_end;
                        }
+                       else srch ++;
+
                }
 
        }
index 57decd88750e41bbdf72c8608cf097525a806f95..acb1a0087d28f89a21bcbd401ec32c3e741d66c0 100644 (file)
@@ -145,12 +145,17 @@ static void mime_download(char *name,
                                      encoding,
                                      &decoded,
                                      &bytes_decoded);
-               if ((rc < 0) || (decoded == NULL)) {
+               if (rc < 0) {
                        printf("failed to decode content\n");
                        return;
                }
-               rc = write(STDOUT_FILENO, content, length);
-               free(decoded);
+               if (rc == 0){
+                       rc = write(STDOUT_FILENO, content, length);
+               }
+               else {
+                       rc = write(STDOUT_FILENO, decoded, bytes_decoded);
+                       free(decoded);
+               }
        }
 }