Skip to content

Commit 7ba943e

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); > | ^~~~~~~~ TRUNC
1 parent 7da19a8 commit 7ba943e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libvisual/libvisual/lv_plugin.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ const char *visual_plugin_get_prev_by_name (VisList *list, const char *name)
532532
static int plugin_add_dir_to_list (VisList *list, const char *dir)
533533
{
534534
VisPluginRef **ref;
535-
char temp[FILENAME_MAX];
535+
char temp[FILENAME_MAX + 1 + FILENAME_MAX + 1];
536536
int i, j, n;
537537
size_t len;
538538
int cnt = 0;
@@ -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)