[PATCH] Bug 9076 - Whois using a non working host for queries by default

Rob Landley rob at landley.net
Tue Jul 5 02:36:07 UTC 2016


On 07/04/2016 02:47 PM, Vito Mulè wrote:
> stopped using strcpy,

Why?

> +    size_t query_len = strlen(argv_host);
> +       char *str_token = malloc(query_len+1 * sizeof(char));

> +       strncpy(str_token, argv_host, query_len+1);

Ignoring the way you've taken 3 lines to say strdup() (and your
sizeof(char) is only applying to the 1, not query_len+1, but it's ok
because sizeof(char) is a constant 1 on every system linux has ever
supported)...

My question is that you're effectively doing:

  strncpy(str_token, argv_host, strlen(argv_host)+1);

So how is this better than strcpy()?

> +       strncpy(host, domain, strlen(domain));

Here you're literally doing that. Why?

Rob


More information about the busybox mailing list