diff mbox series

[hurd,commited,2/4] Subject: hurd: Make __realpath return EINVAL on NULL buf

Message ID 20230803204827.1193126-3-samuel.thibault@ens-lyon.org
State New
Headers show
Series [hurd,commited,1/4] tst-*glob*: Do not check d_name size | expand

Commit Message

Samuel Thibault Aug. 3, 2023, 8:48 p.m. UTC
As Posix and stdlib/test-canon.c expects it, and rather than letting
pathconf crash.
---
 debug/realpath_chk.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/debug/realpath_chk.c b/debug/realpath_chk.c
index adfc09237c..8e734b534e 100644
--- a/debug/realpath_chk.c
+++ b/debug/realpath_chk.c
@@ -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.  */