NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/50909: src/sbin/ifconfig/env.c: 2 * clumsy call to memset ?
On Mon, Mar 07, 2016 at 12:20:00PM +0000, dcb314%hotmail.com@localhost wrote:
> >Number: 50909
> >Category: bin
> >Synopsis: src/sbin/ifconfig/env.c: 2 * clumsy call to memset ?
>
> [src/sbin/ifconfig/env.c:145]: (performance) Buffer 'buf' is being written before its old content has been used.
>
> Source code is
>
> memset(buf, 0, buflen);
> memcpy(buf, prop_data_data_nocopy(data), datalen);
>
> Maybe better code
>
> memcpy(buf, prop_data_data_nocopy(data), datalen);
> memset(buf + datalen, 0, buflen - datalen);
Hold on a minute. The previous code was simpler and more obviously
harmless. Is this change *really* justified on performance grounds? :-)
Dave
--
David Young
dyoung%pobox.com@localhost Urbana, IL (217) 721-9981
Home |
Main Index |
Thread Index |
Old Index