]> diplodocus.org Git - nmh/commitdiff
get_file_info(): Don't return filename from quote onwards on error.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 10 Sep 2017 12:38:18 +0000 (13:38 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 10 Sep 2017 12:51:59 +0000 (13:51 +0100)
If `file_name' contained a quote then `cp' points to it, and remains
pointing to it if any of concat(), popen(3), or fgets(3) fail to give
the expected result.  On returning, cp is not NULL and so strdup(cp) is
returned.  Also, if fgets() fails on Cygwin in the way the comment
describes then cp is wrongly free(3)'d.  (One of the problems with
generic variable names is their overloaded semantics cause faulty
re-use.)  Fixes b4f2851d and 0c50c669.

sbr/mime_type.c

index 25928500cdd8751a2b034cc2718fca7010d4f178..47c6833415df05ca23ae30114088d940ab7cb8e2 100644 (file)
@@ -129,6 +129,7 @@ get_file_info(const char *proc, const char *file_name) {
         quotec = "\"";
     }
 
         quotec = "\"";
     }
 
+    cp = NULL;
     if ((cmd = concat(proc, " ", quotec, file_name, quotec, NULL))) {
         FILE *fp;
 
     if ((cmd = concat(proc, " ", quotec, file_name, quotec, NULL))) {
         FILE *fp;