|
|
bca718 |
commit 58a1335e76a553e1cf4edeebc27f16fc9b53d6e6
|
|
|
bca718 |
Author: Petr Baudis <pasky@ucw.cz>
|
|
|
bca718 |
Date: Thu Mar 14 01:16:53 2013 +0100
|
|
|
bca718 |
|
|
|
bca718 |
Fix __times() handling of EFAULT when buf is NULL
|
|
|
bca718 |
|
|
|
bca718 |
diff --git a/sysdeps/unix/sysv/linux/times.c b/sysdeps/unix/sysv/linux/times.c
|
|
|
bca718 |
index f3b5f01..e59bb4e 100644
|
|
|
bca718 |
--- a/sysdeps/unix/sysv/linux/times.c
|
|
|
bca718 |
+++ b/sysdeps/unix/sysv/linux/times.c
|
|
|
bca718 |
@@ -26,13 +26,14 @@ __times (struct tms *buf)
|
|
|
bca718 |
INTERNAL_SYSCALL_DECL (err);
|
|
|
bca718 |
clock_t ret = INTERNAL_SYSCALL (times, err, 1, buf);
|
|
|
bca718 |
if (INTERNAL_SYSCALL_ERROR_P (ret, err)
|
|
|
bca718 |
- && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0))
|
|
|
bca718 |
+ && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0)
|
|
|
bca718 |
+ && buf)
|
|
|
bca718 |
{
|
|
|
bca718 |
/* This might be an error or not. For architectures which have
|
|
|
bca718 |
no separate return value and error indicators we cannot
|
|
|
bca718 |
distinguish a return value of -1 from an error. Do it the
|
|
|
bca718 |
- hard way. We crash applications which pass in an invalid BUF
|
|
|
bca718 |
- pointer. */
|
|
|
bca718 |
+ hard way. We crash applications which pass in an invalid
|
|
|
bca718 |
+ non-NULL BUF pointer. Linux allows BUF to be NULL. */
|
|
|
bca718 |
#define touch(v) \
|
|
|
bca718 |
do { \
|
|
|
bca718 |
clock_t temp = v; \
|
|
|
bca718 |
@@ -44,7 +45,8 @@ __times (struct tms *buf)
|
|
|
bca718 |
touch (buf->tms_cutime);
|
|
|
bca718 |
touch (buf->tms_cstime);
|
|
|
bca718 |
|
|
|
bca718 |
- /* If we come here the memory is valid and the kernel did not
|
|
|
bca718 |
+ /* If we come here the memory is valid (or BUF is NULL, which is
|
|
|
bca718 |
+ * a valid condition for the kernel syscall) and the kernel did not
|
|
|
bca718 |
return an EFAULT error. Return the value given by the kernel. */
|
|
|
bca718 |
}
|
|
|
bca718 |
|