This is an automated email from Gerrit.

Antonio Borneo ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/5631

-- gerrit

commit 5fb2d90286a52917e6f4a1c31ee3ea664cabd076
Author: Antonio Borneo <[email protected]>
Date:   Mon Apr 27 23:19:14 2020 +0200

    helper/ioutil: fix strncpy limit
    
    The max size parameter of strncpy is the max amount of chars that
    would be copied from source pointer, then a trailing null char
    will be added if not included in the first size chars.
    Thus the size has to be at least one less than the size of the
    destination pointer.
    In current code, size is sizeof of destination pointer, thus too
    high.
    GCC 9.3.0 issue an error:
        error: ‘strncpy’ specified bound 16 equals destination
                size [-Werror=stringop-truncation]
    
    This file is only optionally compiled together with ZY1000 driver
    with --enable-zy1000 --enable-ioutil. This combination is not
    checked in jenkins, so the error passed unnoticed.
    Plus, the configure flags above are both deprecated!
    
    Change-Id: I229e66227cfd3513139feeaffa47a6e1ec00767b
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/src/helper/ioutil.c b/src/helper/ioutil.c
index d4f39e2..c103ce1 100644
--- a/src/helper/ioutil.c
+++ b/src/helper/ioutil.c
@@ -403,7 +403,7 @@ static int ioutil_Jim_Command_mac(Jim_Interp *interp, int 
argc,
                {
                        if (strcmp("eth0", ifr->ifr_name) != 0)
                                continue;
-                       strncpy(ifreq.ifr_name, ifr->ifr_name, 
sizeof(ifreq.ifr_name));
+                       strncpy(ifreq.ifr_name, ifr->ifr_name, 
sizeof(ifreq.ifr_name) - 1);
                        if (ioctl(SockFD, SIOCGIFHWADDR, &ifreq) < 0) {
                                close(SockFD);
                                return JIM_ERR;

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to