uclient-fetch: Check for nullpointer returned by uclient_get_url_filename
authorTobias Schramm <tobleminer@gmail.com>
Sun, 18 Feb 2018 12:46:04 +0000 (13:46 +0100)
committerJohn Crispin <john@phrozen.org>
Tue, 20 Feb 2018 07:16:16 +0000 (08:16 +0100)
uclient_get_url_filename may return a null ptr resulting in a null
ptr dereference by fprintf and open

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
uclient-fetch.c

index 6961d94b12408203bc6ce6bb35d5700082dd9717..38c9c53e35c7f20c4f36d059f5f25673a4e81176 100644 (file)
@@ -122,6 +122,11 @@ static int open_output_file(const char *path, uint64_t resume_offset)
                }
        } else {
                filename = uclient_get_url_filename(path, "index.html");
+               if (!filename) {
+                       ret = -ENOMEM;
+                       goto out;
+               }
+
                output_file = filename;
        }
 
@@ -151,6 +156,7 @@ done:
 
 free:
        free(filename);
+out:
        return ret;
 }