From eefe69c1a7b45d49284073cd6293aebf00a8fd15 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 19 Apr 2021 11:40:07 +0100 Subject: [PATCH] local: Increase temp buffer size for pathname resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes these issues: ../local.c: In function ‘add_scan_elements’: ../local.c:1701:38: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 1023 [-Wformat-truncation=] 1701 | iio_snprintf(buf, sizeof(buf), "%s/%s", path, entry->d_name); | ^~ In file included from ../local.c:10: ../iio-private.h:38:22: note: ‘snprintf’ output between 2 and 1280 bytes into a destination of size 1024 38 | #define iio_snprintf snprintf ../local.c:1701:3: note: in expansion of macro ‘iio_snprintf’ 1701 | iio_snprintf(buf, sizeof(buf), "%s/%s", path, entry->d_name); | ^~~~~~~~~~~~ ../local.c: In function ‘add_buffer_attributes’: ../local.c:1701:38: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 1023 [-Wformat-truncation=] 1701 | iio_snprintf(buf, sizeof(buf), "%s/%s", path, entry->d_name); | ^~ In file included from ../local.c:10: ../iio-private.h:38:22: note: ‘snprintf’ output between 2 and 1280 bytes into a destination of size 1024 38 | #define iio_snprintf snprintf ../local.c:1701:3: note: in expansion of macro ‘iio_snprintf’ 1701 | iio_snprintf(buf, sizeof(buf), "%s/%s", path, entry->d_name); | ^~~~~~~~~~~~ ../local.c: In function ‘local_create_context’: ../local.c:1701:38: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 1023 [-Wformat-truncation=] 1701 | iio_snprintf(buf, sizeof(buf), "%s/%s", path, entry->d_name); | ^~ In file included from ../local.c:10: ../iio-private.h:38:22: note: ‘snprintf’ output between 2 and 1280 bytes into a destination of size 1024 38 | #define iio_snprintf snprintf ../local.c:1701:3: note: in expansion of macro ‘iio_snprintf’ 1701 | iio_snprintf(buf, sizeof(buf), "%s/%s", path, entry->d_name); | ^~~~~~~~~~~~ Signed-off-by: Paul Cercueil --- local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local.c b/local.c index 0c48db600..88a878eaa 100644 --- a/local.c +++ b/local.c @@ -1684,7 +1684,7 @@ static int foreach_in_dir(void *d, const char *path, bool is_dir, while (true) { struct stat st; - char buf[1024]; + char buf[PATH_MAX]; errno = 0; entry = readdir(dir);