[Mesa-dev] [PATCH v6 3/3] gallium/hud: Prevent buffer overflow in hud_thread_busy_install

Robert Foss robert.foss at collabora.com
Wed Jul 5 06:57:41 UTC 2017


Switch to using util_strlcpy to avoid potential overflow of
name array in struct hud_graph.

Coverity-id: 1413760

Signed-off-by: Robert Foss <robert.foss at collabora.com>
---
Changes since v3:
  Matt Turner <mattst88 at gmail.com>
   - Switch from util_strncpy to util_strlcpy
  
  Brian Paul <brianp at vmware.com>
   - Fix comment to mention the correct string copy function
  
Changes since v2:
  Brian Paul <brianp at vmware.com>
   - Switch to using new util_strncpy function

Changes since v1:
  Gustaw Smolarczyk <wielkiegie at gmail.com>
  - Fix strcpy -> strncpy typo

 src/gallium/auxiliary/hud/hud_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c
index 755f8a08bb..55e1b58538 100644
--- a/src/gallium/auxiliary/hud/hud_cpu.c
+++ b/src/gallium/auxiliary/hud/hud_cpu.c
@@ -289,7 +289,7 @@ hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main)
    if (!gr)
       return;
 
-   strcpy(gr->name, name);
+   util_strlcpy(gr->name, name, HUD_GRAPH_NAME_LEN);
 
    gr->query_data = CALLOC_STRUCT(thread_info);
    if (!gr->query_data) {
-- 
2.11.0



More information about the mesa-dev mailing list