* Bug #15213, #18635: The use of the insecure m_scratch() and
[mmh] / uip / mhoutsbr.c
index 2ebdc1f..9235253 100644 (file)
@@ -70,6 +70,7 @@ static char nib2b64[0x40+1] =
  * prototypes
  */
 int output_message (CT, char *);
+int output_message_fp (CT, FILE *, char *);
 int writeBase64aux (FILE *, FILE *);
 
 /*
@@ -90,27 +91,33 @@ static int writeBase64 (CT, FILE *);
  */
 
 int
-output_message (CT ct, char *file)
+output_message_fp (CT ct, FILE *fp, char *file)
 {
-    FILE *fp;
-
-    if ((fp = fopen (file, "w")) == NULL) {
-       advise (file, "unable to open for writing");
-       return NOTOK;
-    }
-
     if (output_content (ct, fp) == NOTOK)
        return NOTOK;
 
     if (fflush (fp)) {
-       advise (file, "error writing to");
+       advise ((file?file:"<FILE*>"), "error writing to");
        return NOTOK;
     }
-    fclose (fp);
-
     return OK;
 }
 
+int
+output_message (CT ct, char *file)
+{
+    FILE *fp;
+    int status;
+
+    if ((fp = fopen (file, "w")) == NULL) {
+       advise (file, "unable to open for writing");
+       return NOTOK;
+    }
+    status = output_message_fp(ct, fp, file);
+    fclose(fp);
+    return status;
+}
+
 
 /*
  * Output a Content structure to a file.