From 8da8929eefd6057e2b1bddf8799554194febc491 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Mon, 23 Dec 2024 20:26:46 +0100 Subject: [PATCH] libvisual/lv_plugin.c: Address warning -Wformat-truncation Symptom was: > ../../libvisual-0.4.2/libvisual/lv_plugin.c: In function 'plugin_add_dir_to_list': > ../../libvisual-0.4.2/libvisual/lv_plugin.c:605:39: error: '%s' directive output may be truncated writing up to 1023 bytes into a region of size 1022 [-Werror=format-truncation=] > 605 | snprintf (temp, 1023, "%s/%s", dir, namelist[i]->d_name); > | ^~~~~~~ > ../../libvisual-0.4.2/libvisual/lv_plugin.c:605:43: note: format string is defined here > 605 | snprintf (temp, 1023, "%s/%s", dir, namelist[i]->d_name); > | ^~ > ../../libvisual-0.4.2/libvisual/lv_plugin.c:605:17: note: '__builtin_snprintf' output 2 or more bytes (assuming 1025) into a destination of size 1023 > 605 | snprintf (temp, 1023, "%s/%s", dir, namelist[i]->d_name); > | ^~~~~~~~ --- libvisual/libvisual/lv_plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libvisual/libvisual/lv_plugin.c b/libvisual/libvisual/lv_plugin.c index 19b996d8d..0c377c889 100644 --- a/libvisual/libvisual/lv_plugin.c +++ b/libvisual/libvisual/lv_plugin.c @@ -562,7 +562,7 @@ static int plugin_add_dir_to_list (VisList *list, const char *dir) if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - snprintf (temp, 1023, "%s\\%s", dir, FileData.cFileName); + snprintf (temp, sizeof (temp), "%s\\%s", dir, FileData.cFileName); len = strlen (temp); if (len > 5 && (strncmp (&temp[len - 5], ".dll", 5) == 0)) @@ -602,7 +602,7 @@ static int plugin_add_dir_to_list (VisList *list, const char *dir) for (i = 2; i < n; i++) { ref = NULL; - snprintf (temp, 1023, "%s/%s", dir, namelist[i]->d_name); + snprintf (temp, sizeof (temp), "%s/%s", dir, namelist[i]->d_name); len = strlen (temp); if (len > 3 && (strncmp (&temp[len - 3], ".so", 3) == 0))