From: Jens Axboe Date: Wed, 7 Jun 2017 16:45:46 +0000 (-0600) Subject: diskutil: ensure we have enough room to not write past end X-Git-Tag: fio-2.21~19 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=5ccdfd74e2e13c61eec307e53a50f3f73f0afe7a;ds=sidebyside diskutil: ensure we have enough room to not write past end 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 --- 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;