From 8638b8cc739ff7b775681d489c608e54a0883b39 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 2 May 2013 13:58:07 -0700 Subject: [PATCH] Make sure stat calls diagnose EFAULT for a NULL struct stat *. --- sysdeps/nacl/xstatconv.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sysdeps/nacl/xstatconv.c b/sysdeps/nacl/xstatconv.c index 6f4cceed78e..29f8427eaed 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: -- 2.47.2