From 9470db92f47ce79ad18c3476561119d428f81c65 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 27 Sep 2019 09:02:53 +0200 Subject: LibC: realpath() should assume the buffer is PATH_MAX bytes --- Libraries/LibC/unistd.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'Libraries') diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp index 831f9c99ad..d465792cab 100644 --- a/Libraries/LibC/unistd.cpp +++ b/Libraries/LibC/unistd.cpp @@ -591,13 +591,9 @@ int umount(const char* mountpoint) char* realpath(const char* pathname, char* buffer) { - size_t size; - if (buffer == nullptr) { - size = PATH_MAX; + size_t size = PATH_MAX; + if (buffer == nullptr) buffer = (char*)malloc(size); - } else { - size = sizeof(buffer); - } int rc = syscall(SC_realpath, pathname, buffer, size); if (rc < 0) { errno = -rc; -- cgit v1.2.3