[OpenWrt-Devel] [PATCH v2 1/7] uclient-fetch: Check for nullpointer returned by uclient_get_url_filename

Tobias Schramm tobleminer at gmail.com
Sun Feb 18 07:46:04 EST 2018


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 at gmail.com>
---
 uclient-fetch.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/uclient-fetch.c b/uclient-fetch.c
index 6961d94..38c9c53 100644
--- a/uclient-fetch.c
+++ b/uclient-fetch.c
@@ -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;
 }
 
-- 
2.16.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list