]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Subject: hurd: Make __realpath return EINVAL on NULL buf
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 3 Aug 2023 19:15:58 +0000 (21:15 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 3 Aug 2023 20:42:29 +0000 (22:42 +0200)
As Posix and stdlib/test-canon.c expects it, and rather than letting
pathconf crash.

debug/realpath_chk.c

index adfc09237cb2b8f51af7e283700836ce25a7e19d..8e734b534e0c966948382c94f24b6ebcfbea95e9 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 
 
 char *
@@ -30,7 +31,15 @@ __realpath_chk (const char *buf, char *resolved, size_t resolvedlen)
 
   return __realpath (buf, resolved);
 #else
-  long int pathmax =__pathconf (buf, _PC_PATH_MAX);
+  long int pathmax;
+
+  if (buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return NULL;
+    }
+
+  pathmax = __pathconf (buf, _PC_PATH_MAX);
   if (pathmax != -1)
     {
       /* We do have a fixed limit.  */