NetBSD-Bugs archive

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

lib/50907: src/lib/libresolv/hmac_link.c: clumsy call to memset ?



>Number:         50907
>Category:       lib
>Synopsis:       src/lib/libresolv/hmac_link.c: clumsy call to memset ?
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 07 12:10:00 +0000 2016
>Originator:     David Binderman
>Release:        cvs dated 20160305
>Organization:
>Environment:
>Description:
[src/lib/libresolv/hmac_link.c:285] -> [src/lib/libresolv/hmac_link.c:287]: (performance) Buffer 'buff' is being written before its old content has been used.

Source code is

    memset(buff, 0, buff_len);  /*%< just in case */
    /* write file header */
    snprintf(buff, buff_len, KEY_FILE_FMT_STR, KEY_FILE_FORMAT,
        KEY_HMAC_MD5, "HMAC");

    bp = buff + strlen(buff);

Maybe better code

    /* write file header */
    snprintf(buff, buff_len, KEY_FILE_FMT_STR, KEY_FILE_FORMAT,
        KEY_HMAC_MD5, "HMAC");

    bp = buff + strlen(buff);
    memset(bp, 0, buff_len - (bp - buff));  /*%< just in case */

>How-To-Repeat:

>Fix:



Home | Main Index | Thread Index | Old Index