summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2013-05-02 13:58:07 -0700
committerRoland McGrath <roland@hack.frob.com>2013-05-02 13:58:07 -0700
commit8638b8cc739ff7b775681d489c608e54a0883b39 (patch)
tree194b988af540055e1e253c95b749ff3aa7d3edc9
parent1b5fa03f65274e86a606931e8d47a596718a4756 (diff)
downloadglibc-8638b8cc739ff7b775681d489c608e54a0883b39.tar.gz
glibc-8638b8cc739ff7b775681d489c608e54a0883b39.tar.xz
glibc-8638b8cc739ff7b775681d489c608e54a0883b39.zip
Make sure stat calls diagnose EFAULT for a NULL struct stat *.
-rw-r--r--sysdeps/nacl/xstatconv.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sysdeps/nacl/xstatconv.c b/sysdeps/nacl/xstatconv.c
index 6f4cceed78..29f8427eae 100644
--- a/sysdeps/nacl/xstatconv.c
+++ b/sysdeps/nacl/xstatconv.c
@@ -24,6 +24,15 @@ internal_function
 int
 __xstat_conv (int vers, const struct nacl_abi_stat *kbuf, void *ubuf)
 {
+  /* It's kosher enough just to crash here, but there are some
+     existing NaCl tests that like to see EFAULT, and that's what
+     making the IRT call with NULL would give.  */
+  if (__glibc_unlikely (ubuf == NULL))
+    {
+      __set_errno (EFAULT);
+      return -1;
+    }
+
   switch (vers)
     {
     case _STAT_VER_NACL: