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

[xen stable-4.9] tools/gdbsx: fix -Wstringop-truncation warning



commit f1e75e5c7054d8cd7bdfe30c6a95af35cc24fbb2
Author:     Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
AuthorDate: Thu Apr 5 03:50:54 2018 +0200
Commit:     Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CommitDate: Fri Jun 12 17:01:39 2020 +0100

    tools/gdbsx: fix -Wstringop-truncation warning
    
    gcc-8 complains:
    
        gx_main.c: In function 'prepare_stop_reply':
        gx_main.c:385:9: error: 'strncpy' output truncated before terminating 
nul copying 6 bytes from a string of the same length 
[-Werror=stringop-truncation]
                 strncpy(buf, "watch:", 6);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
    
    Since terminating '\0' isn't needed here at all, switch to memcpy.
    
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
    Release-Acked-by: Juergen Gross <jgross@xxxxxxxx>
    (cherry picked from commit 7f601f7c341c80d554615556d60e3b8ed1e5ad4f)
---
 tools/debugger/gdbsx/gx/gx_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/debugger/gdbsx/gx/gx_main.c 
b/tools/debugger/gdbsx/gx/gx_main.c
index a908c45e1d..6dfa501145 100644
--- a/tools/debugger/gdbsx/gx/gx_main.c
+++ b/tools/debugger/gdbsx/gx/gx_main.c
@@ -382,7 +382,7 @@ prepare_stop_reply(enum target_signal sig, char *buf, 
vcpuid_t vcpu)
 
     /* TBD: check if we stopped because of watchpoint */
     if (watchpoint_stop()) {
-        strncpy(buf, "watch:", 6);
+        memcpy(buf, "watch:", 6);
         buf += 6;
         /* TBD: **/
     }
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.9



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.