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 ?



The following reply was made to PR bin/50909; it has been noted by GNATS.

From: David Young <dyoung%pobox.com@localhost>
To: gnats-bugs%NetBSD.org@localhost, christos%netbsd.org@localhost, dcb314%hotmail.com@localhost
Cc: gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Subject: Re: bin/50909: src/sbin/ifconfig/env.c: 2 * clumsy call to memset ?
Date: Mon, 7 Mar 2016 13:12:38 -0600

 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