Skip to content

Commit 8da8929

Browse files
committed
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); > | ^~~~~~~~
1 parent 1e9d813 commit 8da8929

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libvisual/libvisual/lv_plugin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ static int plugin_add_dir_to_list (VisList *list, const char *dir)
562562

563563
if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
564564

565-
snprintf (temp, 1023, "%s\\%s", dir, FileData.cFileName);
565+
snprintf (temp, sizeof (temp), "%s\\%s", dir, FileData.cFileName);
566566

567567
len = strlen (temp);
568568
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)
602602
for (i = 2; i < n; i++) {
603603
ref = NULL;
604604

605-
snprintf (temp, 1023, "%s/%s", dir, namelist[i]->d_name);
605+
snprintf (temp, sizeof (temp), "%s/%s", dir, namelist[i]->d_name);
606606

607607
len = strlen (temp);
608608
if (len > 3 && (strncmp (&temp[len - 3], ".so", 3) == 0))

0 commit comments

Comments
 (0)