[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#357163: metamail: dumps core with -w option



On Fri, Mar 17, 2006 at 03:12:12PM -0500, Norman Ramsey wrote:
>  > tag 357163 confirmed patch
>  > thanks
> 
> Wow!  That's a fast fix.
> 
> Unfortunately there is a new bug: if the recommended filename (from
> the Content-Type: header) is written as a quoted string, the quotes
> become part of the filename.  But the MIME standard says
> 
>    Note that the value of a quoted string parameter does not include
>    the quotes.  That is, the quotation marks in a quoted-string are
>    not a part of the value of the parameter, but are merely used to
>    delimit that parameter value.
> 
> Do you want me to post another bug to the reporting system?
Nope, it was introduced by my carelessness; here's another patch :)

Justin,
who is waiting to hear back from a position at iq.harvard.edu, where
he interviewed in February
--- old/metamail.c	2006-03-17 15:30:37.000000000 -0500
+++ metamail.c	2006-03-17 15:35:12.000000000 -0500
@@ -381,18 +381,21 @@
         char Fname[NAME_MAX], *suggestedname, SugBuf[NAME_MAX];
         FILE *fp;
         int ans = 0, octetstream, ecode=0;
+	int JustMadeTheFile=0;
 	
 	Fname[0] = 0;
 
         suggestedname = FindParam("name");
-        if (strlen(suggestedname) > NAME_MAX - 50)
-            suggestedname[NAME_MAX - 50] = '\0';
         if (!suggestedname) {
             MkTmpFileName(SugBuf);
+	    JustMadeTheFile=1;
             suggestedname = SugBuf;
-        } else if (suggestedname[0] == '"') {
-            suggestedname=UnquoteString(suggestedname);
-        }
+	}
+	if (strlen(suggestedname) > NAME_MAX - 50)
+            suggestedname[NAME_MAX - 50] = '\0';
+	if (suggestedname[0] == '"')
+		suggestedname=UnquoteString(suggestedname);
+
         octetstream = ! lc2strcmp(ContentType, "application/octet-stream");
         if (MightAskBeforeExecuting && !DefinitelyNotTty && !MustNotBeTty) {
             if (FileWriteOnly) {
@@ -450,7 +453,7 @@
 			    
 			    if (DoDebug) fprintf(stderr, "pre access");
 
-                            if (access(Fname, F_OK) == 0) {
+                            if (!JustMadeTheFile && access(Fname, F_OK) == 0) {
                                 char *s, AnsBuf[50];
                                 int overwriteans = -1;
                                 do {

Reply to: