NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/50909: src/sbin/ifconfig/env.c: 2 * clumsy call to memset ?



>Number:         50909
>Category:       bin
>Synopsis:       src/sbin/ifconfig/env.c: 2 * clumsy call to memset ?
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 07 12:20:00 +0000 2016
>Originator:     David Binderman
>Release:        cvs dated 20160305
>Organization:
>Environment:
>Description:

1.

[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);


>How-To-Repeat:

>Fix:



Home | Main Index | Thread Index | Old Index