[Spice-devel] [PATCH spice-server 2/2] red-worker: Avoid possible string formatting warning

Frediano Ziglio fziglio at redhat.com
Wed Mar 20 14:51:29 UTC 2019


Although id is not supposed to be big prevent possible
warning/overflow.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-worker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

This was signaled by Christophe Fergeau

diff --git a/server/red-worker.c b/server/red-worker.c
index 8051d1e4..a25a0cd8 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1291,7 +1291,7 @@ RedWorker* red_worker_new(QXLInstance *qxl,
     worker->zlib_glz_state = reds_get_zlib_glz_state(reds);
     worker->driver_cap_monitors_config = 0;
     char worker_str[SPICE_STAT_NODE_NAME_MAX];
-    sprintf(worker_str, "display[%d]", worker->qxl->id);
+    snprintf(worker_str, sizeof(worker_str), "display[%d]", worker->qxl->id);
     stat_init_node(&worker->stat, reds, NULL, worker_str, TRUE);
     stat_init_counter(&worker->wakeup_counter, reds, &worker->stat, "wakeups", TRUE);
     stat_init_counter(&worker->command_counter, reds, &worker->stat, "commands", TRUE);
-- 
2.20.1



More information about the Spice-devel mailing list