]> code.citadel.org Git - citadel.git/blobdiff - citadel/mime_parser.c
fixes for BSDI. see ChangeLog.
[citadel.git] / citadel / mime_parser.c
index 2b0d70710a07f451c850f22635d63cd38f90ab89..bc046ba8e27c963c7f2aeeadaacbade62fade08d 100644 (file)
@@ -9,6 +9,7 @@
  *
  */
 
+#include "sysdep.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <errno.h>
+#ifdef HAVE_PTHREAD_H
 #include <pthread.h>
+#endif
 #include "citadel.h"
 #include "mime_parser.h"
 #include "sysdep_decls.h"
@@ -123,9 +127,10 @@ void mime_decode(char *partnum,
         * 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.
+        * assumption with base64, uuencode, and quoted-printable.  Just to
+        * be safe, we still pad the buffer a bit.
         */
-       decoded = mallok(length);
+       decoded = mallok(length + 1024);
        if (decoded == NULL) {
                lprintf(5, "ERROR: cannot allocate memory.\n");
                return;
@@ -140,7 +145,7 @@ void mime_decode(char *partnum,
                }
 
        if (childpid == 0) {
-               /* close(2); FIX uncomment this when solid */
+               close(2);
                /* send stdio to the pipes */
                if (dup2(sendpipe[0], 0)<0) lprintf(5, "ERROR dup2()\n");
                if (dup2(recvpipe[1], 1)<0) lprintf(5, "ERROR dup2()\n");
@@ -187,6 +192,7 @@ void mime_decode(char *partnum,
        if (bytes_recv > 0)
                CallBack(name, filename, partnum, disposition, decoded,
                        content_type, bytes_recv);
+
        phree(decoded);
        }