[Dnsmasq-discuss] [PATCH] Fix some errors and warnings from clang-analyzer
Pali Rohár
pali.rohar at gmail.com
Thu Oct 5 08:48:03 BST 2017
On Wednesday 04 October 2017 19:22:11 Rosen Penev wrote:
> diff --git a/src/cache.c b/src/cache.c
> index 4f43246..88851e7 100644
> --- a/src/cache.c
> +++ b/src/cache.c
> @@ -572,7 +572,7 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
> }
>
> if (name)
> - strcpy(cache_get_name(new), name);
> + strncpy(cache_get_name(new), name, strlen(cache_get_name(new)));
Hi! This line looks suspicious. Should not be length argument sizeof of
destination buffer, instead of current length of null term string?
Also strncpy in some circumstances fill string which is not null
terminated.
--
Pali Rohár
pali.rohar at gmail.com
More information about the Dnsmasq-discuss
mailing list