]> code.citadel.org Git - citadel.git/commitdiff
mime_parser.c: pad the encoded-to-unencoded buffer
authorArt Cancro <ajc@citadel.org>
Wed, 3 May 2006 03:27:19 +0000 (03:27 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 3 May 2006 03:27:19 +0000 (03:27 +0000)
a bit more, because certain MIME parts (such as tnef) were blowing the target
buffer.  This fixes a problem whose symptom is a server crash during fulltext
indexing.

citadel/mime_parser.c

index 726ab74a6bc10cd61df3612f37d8b4f4322e99b4..572e627aaef8a05c4276a34f2667433299eaf0c1 100644 (file)
@@ -197,12 +197,12 @@ void mime_decode(char *partnum,
                return;
        }
        /*
-        * Allocate a buffer for the decoded data.  The output buffer is the
-        * same size as the input buffer; this assumes that the decoded data
-        * will never be larger than the encoded data.  This is a safe
-        * assumption with base64, uuencode, and quoted-printable.
+        * Allocate a buffer for the decoded data.  The output buffer is slightly
+        * larger than the input buffer; this assumes that the decoded data
+        * will never be significantly larger than the encoded data.  This is a
+        * safe assumption with base64, uuencode, and quoted-printable.
         */
-       decoded = malloc(length+2048);
+       decoded = malloc(length + 32768);
        if (decoded == NULL) {
                return;
        }
@@ -211,8 +211,7 @@ void mime_decode(char *partnum,
                bytes_decoded = CtdlDecodeBase64(decoded, part_start, length);
        }
        else if (!strcasecmp(encoding, "quoted-printable")) {
-               bytes_decoded = CtdlDecodeQuotedPrintable(decoded,
-                                                       part_start, length);
+               bytes_decoded = CtdlDecodeQuotedPrintable(decoded, part_start, length);
        }
 
        if (bytes_decoded > 0) if (CallBack != NULL) {