[OpenWrt-Devel] [PATCH v2 7/7] uclient: Handle memory allocation failure for url

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


Check ptr to url after allocation to prevent null pointer
dereference

Signed-off-by: Tobias Schramm <tobleminer at gmail.com>
---
 uclient.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/uclient.c b/uclient.c
index 8862b55..1137168 100644
--- a/uclient.c
+++ b/uclient.c
@@ -59,6 +59,9 @@ __uclient_get_url(const struct uclient_backend *backend,
 		&uri_buf, strlen(location) + 1,
 		&auth_buf, auth_str ? strlen(auth_str) + 1 : 0);
 
+	if (!url)
+		return NULL;
+
 	url->backend = backend;
 	url->location = strcpy(uri_buf, location);
 	if (host)
-- 
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