]> diplodocus.org Git - nmh/blobdiff - uip/mhfixmsg.c
Use a dynamically-allocated buffer for character set conversion, and
[nmh] / uip / mhfixmsg.c
index f00fc97d06a71f5329f4270991abefe14515cb02..97cbab07905f32998e392a2a3830474451cae134 100644 (file)
@@ -60,7 +60,7 @@ void reverse_parts (CT);
 int output_message (CT, char *);
 
 /* mhshowsbr.c */
 int output_message (CT, char *);
 
 /* mhshowsbr.c */
-int show_content_aux (CT, int, int, char *, char *);
+int show_content_aux (CT, int, char *, char *);
 
 /* mhmisc.c */
 void flush_errors (void);
 
 /* mhmisc.c */
 void flush_errors (void);
@@ -563,10 +563,11 @@ get_multipart_boundary (CT ct, char **part_boundary) {
     while (begin >= (off_t) ct->c_begin) {
         fseeko (ct->c_fp, begin, SEEK_SET);
         while ((bytes_read = fread (buffer, 1, sizeof buffer, ct->c_fp)) > 0) {
     while (begin >= (off_t) ct->c_begin) {
         fseeko (ct->c_fp, begin, SEEK_SET);
         while ((bytes_read = fread (buffer, 1, sizeof buffer, ct->c_fp)) > 0) {
-            char *end = buffer + bytes_read - 1;
-            char *cp;
+            char *cp = rfind_str (buffer, bytes_read, "--");
+
+            if (cp) {
+                char *end;
 
 
-            if ((cp = rfind_str (buffer, bytes_read, "--"))) {
                 /* Trim off trailing "--" and anything beyond. */
                 *cp-- = '\0';
                 if ((end = rfind_str (buffer, cp - buffer, "\n"))) {
                 /* Trim off trailing "--" and anything beyond. */
                 *cp-- = '\0';
                 if ((end = rfind_str (buffer, cp - buffer, "\n"))) {
@@ -1127,7 +1128,7 @@ reformat_part (CT ct, char *file, char *type, char *subtype, int c_type) {
     free (cp);
 
     cp = concat (cf, " >", file, NULL);
     free (cp);
 
     cp = concat (cf, " >", file, NULL);
-    status = show_content_aux (ct, 1, 0, cp, NULL);
+    status = show_content_aux (ct, 0, cp, NULL);
     free (cp);
 
     /* Unlink decoded content tmp file and free its filename to avoid
     free (cp);
 
     /* Unlink decoded content tmp file and free its filename to avoid
@@ -1195,7 +1196,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
        c_cefile, c_encoding,
        c_digested, c_digest[16], c_ctexbody,
        c_ctinitfnx, c_ceopenfnx, c_ceclosefnx, c_cesizefnx,
        c_cefile, c_encoding,
        c_digested, c_digest[16], c_ctexbody,
        c_ctinitfnx, c_ceopenfnx, c_ceclosefnx, c_cesizefnx,
-       c_umask, c_pid, c_rfc934,
+       c_umask, c_rfc934,
        c_showproc, c_termproc, c_storeproc, c_storage, c_folder
     */
 
        c_showproc, c_termproc, c_storeproc, c_storage, c_folder
     */
 
@@ -1222,6 +1223,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
                      boundary_in_content (&new_part->c_cefile.ce_fp,
                                           new_part->c_cefile.ce_file,
                                           boundary)) == -1) {
                      boundary_in_content (&new_part->c_cefile.ce_fp,
                                           new_part->c_cefile.ce_file,
                                           boundary)) == -1) {
+                    free (ct);
                     return NULL;
                 }
             }
                     return NULL;
                 }
             }
@@ -1232,6 +1234,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
                 if ((found_boundary = boundary_in_content (&new_part->c_fp,
                                                            new_part->c_file,
                                                            boundary)) == -1) {
                 if ((found_boundary = boundary_in_content (&new_part->c_fp,
                                                            new_part->c_file,
                                                            boundary)) == -1) {
+                    free (ct);
                     return NULL;
                 }
             }
                     return NULL;
                 }
             }
@@ -1252,6 +1255,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
 
         if (found_boundary) {
             advise (NULL, "giving up trying to find a unique boundary");
 
         if (found_boundary) {
             advise (NULL, "giving up trying to find a unique boundary");
+            free (ct);
             return NULL;
         }
     }
             return NULL;
         }
     }