浏览代码

LibC: realpath() should assume the buffer is PATH_MAX bytes

Andreas Kling 5 年之前
父节点
当前提交
9470db92f4
共有 1 个文件被更改,包括 2 次插入6 次删除
  1. 2 6
      Libraries/LibC/unistd.cpp

+ 2 - 6
Libraries/LibC/unistd.cpp

@@ -591,13 +591,9 @@ int umount(const char* mountpoint)
 
 
 char* realpath(const char* pathname, char* buffer)
 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);
         buffer = (char*)malloc(size);
-    } else {
-        size = sizeof(buffer);
-    }
     int rc = syscall(SC_realpath, pathname, buffer, size);
     int rc = syscall(SC_realpath, pathname, buffer, size);
     if (rc < 0) {
     if (rc < 0) {
         errno = -rc;
         errno = -rc;