uclient: Handle memory allocation failure for url
authorTobias Schramm <tobleminer@gmail.com>
Sun, 18 Feb 2018 12:46:10 +0000 (13:46 +0100)
committerJohn Crispin <john@phrozen.org>
Tue, 20 Feb 2018 07:29:00 +0000 (08:29 +0100)
Check ptr to url after allocation to prevent null pointer
dereference

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

index 8862b557b975204d723923c4c3ab64ffea8763e9..11371684e8a15cdd8566263d2a3b8b670880b7a2 100644 (file)
--- 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)