[Top][All Lists]

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

[Qemu-devel] [PATCH PULL 4/4] hw/rdma: avoid suspicious strncpy() use

From: Marcel Apfelbaum
Subject: [Qemu-devel] [PATCH PULL 4/4] hw/rdma: avoid suspicious strncpy() use
Date: Sat, 21 Mar 2020 21:13:11 +0200

From: Stefan Hajnoczi <address@hidden>

gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1) with sanitizers enabled
reports the following error:

  CC      x86_64-softmmu/hw/rdma/vmw/pvrdma_dev_ring.o
In file included from /usr/include/string.h:495,
                 from include/qemu/osdep.h:101,
                 from hw/rdma/vmw/pvrdma_dev_ring.c:16:
In function ‘strncpy’,
    inlined from ‘pvrdma_ring_init’ at hw/rdma/vmw/pvrdma_dev_ring.c:33:5:
/usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ 
specified bound 32 equals destination size [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Use pstrcpy() instead of strncpy().  It is guaranteed to NUL-terminate

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Yuval Shaia <yuval.shaia.ml.gmail.com>
Message-Id: <address@hidden>
Signed-off-by: Marcel Apfelbaum <address@hidden>
 hw/rdma/vmw/pvrdma_dev_ring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/rdma/vmw/pvrdma_dev_ring.c b/hw/rdma/vmw/pvrdma_dev_ring.c
index c2b3dd70a9..c122fe7035 100644
--- a/hw/rdma/vmw/pvrdma_dev_ring.c
+++ b/hw/rdma/vmw/pvrdma_dev_ring.c
@@ -14,6 +14,7 @@
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "hw/pci/pci.h"
 #include "cpu.h"
 #include "qemu/cutils.h"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]