From f3707a5a0c4483b15e7bb2ba9f0e7d1913a713ee Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Tue, 11 Sep 2012 09:58:32 -0300 Subject: [PATCH] QFileSystemEngine: fix realpath() buffer size realpath() returns at most PATH_MAX _plus_ the terminator. Change-Id: I4c2e3e166a5f476863ad8c6999800e6468535dbe Reviewed-by: Qt Doc Bot Reviewed-by: Thomas McGuire Reviewed-by: Giuseppe D'Angelo --- src/corelib/io/qfilesystemengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 1bc3c4dea6..3d75b8cb09 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -194,7 +194,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, # if _POSIX_VERSION >= 200801L ret = realpath(entry.nativeFilePath().constData(), (char*)0); # else - ret = (char*)malloc(PATH_MAX); + ret = (char*)malloc(PATH_MAX + 1); if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) { const int savedErrno = errno; // errno is checked below, and free() might change it free(ret);