From 5983df320af003a10ab2b965db1eecaca92c7056 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Mon, 18 Dec 2017 22:54:01 +0000 Subject: Fix truncation warnings in posix/tst-glob_symlinks.c. The test posix/tst-glob_symlinks.c fails to build with GCC mainline: tst-glob_symlinks.c: In function 'do_test': tst-glob_symlinks.c:124:30: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=] snprintf (buf, sizeof buf, "%s?", dangling_link); ^~~~~ tst-glob_symlinks.c:124:3: note: 'snprintf' output between 2 and 4097 bytes into a destination of size 4096 snprintf (buf, sizeof buf, "%s?", dangling_link); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tst-glob_symlinks.c:128:30: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=] snprintf (buf, sizeof buf, "%s*", dangling_link); ^~~~~ tst-glob_symlinks.c:128:3: note: 'snprintf' output between 2 and 4097 bytes into a destination of size 4096 snprintf (buf, sizeof buf, "%s*", dangling_link); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This patch fixes the test to avoid such truncation warnings by increasing the buffer in question by one byte, to ensure it can hold any possible result of %s? or %s* formats where %s comes from a buffer of size PATH_MAX. Tested compilation with build-many-glibcs.py for aarch64-linux-gnu. * posix/tst-glob_symlinks.c (do_test): Increase size of buf. --- posix/tst-glob_symlinks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'posix') diff --git a/posix/tst-glob_symlinks.c b/posix/tst-glob_symlinks.c index 5c4b4ecf4a..3a86f4c8cc 100644 --- a/posix/tst-glob_symlinks.c +++ b/posix/tst-glob_symlinks.c @@ -94,7 +94,7 @@ do_prepare (int argc, char *argv[]) static int do_test (void) { - char buf[PATH_MAX]; + char buf[PATH_MAX + 1]; glob_t gl; TEST_VERIFY_EXIT (glob (valid_link, 0, NULL, &gl) == 0); -- cgit 1.4.1