[OpenWrt-Devel] [PATCH v3 6/7] uclient-utils: Handle memory allocation failure for url file name

Philip Prindeville philipp_subx at redfish-solutions.com
Wed Feb 21 20:02:34 EST 2018


LGTM


> On Feb 20, 2018, at 3:26 AM, Tobias Schramm <tobleminer at gmail.com> wrote:
> 
> Add null pointer check to allocation of url filename
> 
> Signed-off-by: Tobias Schramm <tobleminer at gmail.com>
> ---
> uclient-utils.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/uclient-utils.c b/uclient-utils.c
> index a375eea..3eaf2d5 100644
> --- a/uclient-utils.c
> +++ b/uclient-utils.c
> @@ -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);
> }
> -- 
> 2.16.2
_______________________________________________
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