From 1f107ce6bdadbe7ce9069974236c874984fa364e Mon Sep 17 00:00:00 2001 From: Erik Jonsson Thoren Date: Tue, 23 Jun 2015 13:09:10 +0200 Subject: [PATCH] Pass NULL pointer as second argument to realpath to get pointer to the path. Avoids buffer overflow error. This is standard behavior as of POSIX 2008 --- src/utilities.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utilities.c b/src/utilities.c index 61b4f85..cd4d817 100644 --- a/src/utilities.c +++ b/src/utilities.c @@ -301,7 +301,7 @@ IOR_offset_t StringToBytes(char *size_str) void ShowFileSystemSize(char *fileSystem) { #ifndef _WIN32 /* FIXME */ - char realPath[PATH_MAX]; + char *realPath; char *fileSystemUnitStr; long long int totalFileSystemSize; long long int freeFileSystemSize; @@ -352,7 +352,8 @@ void ShowFileSystemSize(char *fileSystem) (1 - ((double)freeInodes / (double)totalInodes)) * 100; /* show results */ - if (realpath(fileSystem, realPath) == NULL) { + realPath = realpath(fileSystem, NULL); + if (realPath == NULL) { ERR("unable to use realpath()"); } fprintf(stdout, "Path: %s\n", realPath);