NetBSD-Bugs archive

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

bin/50910: src/sbin/newfs/mkfs.c:739: clumsy call to memset ?



>Number:         50910
>Category:       bin
>Synopsis:       src/sbin/newfs/mkfs.c:739: 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:

src/sbin/newfs/mkfs.c:739]: (performance) Buffer 'iobuf' is being written before its old content has been used.

Source code is

    memset(iobuf, 0, i);
    memcpy(iobuf, &sblock, sizeof sblock);

Maybe better code
   
    memcpy(iobuf, &sblock, sizeof sblock);
    memset(iobuf + sizeof sblock, 0, i - sizeof sblock);

>How-To-Repeat:

>Fix:



Home | Main Index | Thread Index | Old Index