From 5ccdfd74e2e13c61eec307e53a50f3f73f0afe7a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 7 Jun 2017 10:45:46 -0600 Subject: [PATCH] diskutil: ensure we have enough room to not write past end MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit gcc 7.1 triggers this warning: diskutil.c: In function ‘find_block_dir’: diskutil.c:371:22: warning: ‘__builtin___sprintf_chk’ may write a terminating nul past the end of the destination [-Wformat-overflow=] sprintf(full_path, "%s/%s", path, dir->d_name); ^~~~~~~ In file included from /usr/include/stdio.h:936:0, from diskutil.c:1: Ensure that it's 256+1 in length. Signed-off-by: Jens Axboe --- diskutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diskutil.c b/diskutil.c index dca37483..9767ea25 100644 --- a/diskutil.c +++ b/diskutil.c @@ -363,7 +363,7 @@ static int find_block_dir(int majdev, int mindev, char *path, int link_ok) return 0; while ((dir = readdir(D)) != NULL) { - char full_path[256]; + char full_path[257]; if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, "..")) continue; -- 2.25.1