2 # Derived from this upstream commit:
4 # commit 58a1335e76a553e1cf4edeebc27f16fc9b53d6e6
5 # Author: Petr Baudis <pasky@ucw.cz>
6 # Date: Thu Mar 14 01:16:53 2013 +0100
8 # Fix __times() handling of EFAULT when buf is NULL
10 # 2013-03-14 Petr Baudis <pasky@ucw.cz>
12 # * sysdeps/unix/sysv/linux/times.c (__times): On EFAULT, test
13 # for non-NULL pointer before the memory validity test. Pointed
14 # out by Holger Brunck <holger.brunck@keymile.com>.
16 diff --git a/sysdeps/unix/sysv/linux/times.c b/sysdeps/unix/sysv/linux/times.c
17 index f3b5f01..e59bb4e 100644
18 --- a/sysdeps/unix/sysv/linux/times.c
19 +++ b/sysdeps/unix/sysv/linux/times.c
20 @@ -26,13 +26,14 @@ __times (struct tms *buf)
21 INTERNAL_SYSCALL_DECL (err);
22 clock_t ret = INTERNAL_SYSCALL (times, err, 1, buf);
23 if (INTERNAL_SYSCALL_ERROR_P (ret, err)
24 - && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0))
25 + && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0)
28 /* This might be an error or not. For architectures which have
29 no separate return value and error indicators we cannot
30 distinguish a return value of -1 from an error. Do it the
31 - hard way. We crash applications which pass in an invalid BUF
33 + hard way. We crash applications which pass in an invalid
34 + non-NULL BUF pointer. Linux allows BUF to be NULL. */
38 @@ -44,7 +45,8 @@ __times (struct tms *buf)
39 touch (buf->tms_cutime);
40 touch (buf->tms_cstime);
42 - /* If we come here the memory is valid and the kernel did not
43 + /* If we come here the memory is valid (or BUF is NULL, which is
44 + * a valid condition for the kernel syscall) and the kernel did not
45 return an EFAULT error. Return the value given by the kernel. */