uclient-utils: Handle memory allocation failure for url file name
authorTobias Schramm <tobleminer@gmail.com>
Tue, 20 Feb 2018 10:26:31 +0000 (11:26 +0100)
committerFelix Fietkau <nbd@nbd.name>
Thu, 22 Feb 2018 16:52:04 +0000 (17:52 +0100)
Add null pointer check to allocation of url filename

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

index a375eeacb33eceb0925d947da156f3e722d5f94d..3eaf2d5febe2f38bebdd4921f0c4a449a41f5537 100644 (file)
@@ -178,7 +178,7 @@ char *uclient_get_url_filename(const char *url, const char *default_name)
        len -= str - url;
 
        if (len > 0)
-               return strncpy(calloc(1, len + 1), str, len);
+               return strndup(str, len);
 
        return strdup(default_name);
 }