Skip to content

Commit

Permalink
libsemanage: Fix snprintf warnings from gcc 7
Browse files Browse the repository at this point in the history
Fixes the following warning from gcc7 by increasing the
buffer size to PATH_MAX.

semanage_store.c: In function ‘semanage_remove_directory’:
semanage_store.c:819:30: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 254 [-Wformat-truncation=]
   snprintf(s, sizeof(s), "%s/%s", path, namelist[i]->d_name);
                              ^~
semanage_store.c:819:3: note: ‘snprintf’ output 2 or more bytes (assuming 257) into a destination of size 255
   snprintf(s, sizeof(s), "%s/%s", path, namelist[i]->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Stephen Smalley <[email protected]>
  • Loading branch information
stephensmalley authored and jwcart2 committed Jun 1, 2017
1 parent e41ae67 commit f602443
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libsemanage/src/semanage_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ int semanage_remove_directory(const char *path)
return -1;
}
for (i = 0; i < num_entries; i++) {
char s[NAME_MAX];
char s[PATH_MAX];
struct stat buf;
snprintf(s, sizeof(s), "%s/%s", path, namelist[i]->d_name);
if (stat(s, &buf) == -1) {
Expand Down

0 comments on commit f602443

Please sign in to comment.