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

Rich Felker dalias at libc.org
Tue Jul 5 03:18:50 UTC 2016


On Mon, Jul 04, 2016 at 09:36:07PM -0500, Rob Landley wrote:
> 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)...

Not just Linux. sizeof(char) is literally the answer to the question
"how many chars in a char?" or "how big is char in units of char?"

Rich


More information about the busybox mailing list