gallium/hud: avoid overflowing hud graph name size
authorIlia Mirkin <imirkin@alum.mit.edu>
Thu, 26 Mar 2015 23:37:50 +0000 (19:37 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Fri, 27 Mar 2015 01:02:08 +0000 (21:02 -0400)
Spotted by Coverity.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/hud/hud_driver_query.c

index b48708c2fe6cfb3cbaa453a2c0084da9aec96247..53771fcae9d5f1cdbcf1208b470708109a942d43 100644 (file)
@@ -157,7 +157,8 @@ hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
    if (!gr)
       return;
 
-   strcpy(gr->name, name);
+   strncpy(gr->name, name, sizeof(gr->name));
+   gr->name[sizeof(gr->name) - 1] = '\0';
    gr->query_data = CALLOC_STRUCT(query_info);
    if (!gr->query_data) {
       FREE(gr);