From 2d667ff62463f331fba7dddea084d1ededd24b71 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 10 Sep 2017 13:38:18 +0100 Subject: [PATCH] get_file_info(): Don't return filename from quote onwards on error. 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/sbr/mime_type.c b/sbr/mime_type.c index 25928500..47c68334 100644 --- a/sbr/mime_type.c +++ b/sbr/mime_type.c @@ -129,6 +129,7 @@ get_file_info(const char *proc, const char *file_name) { quotec = "\""; } + cp = NULL; if ((cmd = concat(proc, " ", quotec, file_name, quotec, NULL))) { FILE *fp; -- 2.56.0