mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Fix __times() handling of EFAULT when buf is NULL
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2013-03-14 Petr Baudis <pasky@ucw.cz>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/times.c (__times): On EFAULT, test
|
||||||
|
for non-NULL pointer before the memory validity test. Pointed
|
||||||
|
out by Holger Brunck <holger.brunck@keymile.com>.
|
||||||
|
|
||||||
2013-03-13 Andreas Schwab <schwab@suse.de>
|
2013-03-13 Andreas Schwab <schwab@suse.de>
|
||||||
|
|
||||||
* extra-lib.mk (extra-objs): Add static-only-routines as .oS
|
* extra-lib.mk (extra-objs): Add static-only-routines as .oS
|
||||||
|
@ -26,13 +26,14 @@ __times (struct tms *buf)
|
|||||||
INTERNAL_SYSCALL_DECL (err);
|
INTERNAL_SYSCALL_DECL (err);
|
||||||
clock_t ret = INTERNAL_SYSCALL (times, err, 1, buf);
|
clock_t ret = INTERNAL_SYSCALL (times, err, 1, buf);
|
||||||
if (INTERNAL_SYSCALL_ERROR_P (ret, err)
|
if (INTERNAL_SYSCALL_ERROR_P (ret, err)
|
||||||
&& __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0))
|
&& __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0)
|
||||||
|
&& buf)
|
||||||
{
|
{
|
||||||
/* This might be an error or not. For architectures which have
|
/* This might be an error or not. For architectures which have
|
||||||
no separate return value and error indicators we cannot
|
no separate return value and error indicators we cannot
|
||||||
distinguish a return value of -1 from an error. Do it the
|
distinguish a return value of -1 from an error. Do it the
|
||||||
hard way. We crash applications which pass in an invalid BUF
|
hard way. We crash applications which pass in an invalid
|
||||||
pointer. */
|
non-NULL BUF pointer. Linux allows BUF to be NULL. */
|
||||||
#define touch(v) \
|
#define touch(v) \
|
||||||
do { \
|
do { \
|
||||||
clock_t temp = v; \
|
clock_t temp = v; \
|
||||||
@ -44,7 +45,8 @@ __times (struct tms *buf)
|
|||||||
touch (buf->tms_cutime);
|
touch (buf->tms_cutime);
|
||||||
touch (buf->tms_cstime);
|
touch (buf->tms_cstime);
|
||||||
|
|
||||||
/* If we come here the memory is valid and the kernel did not
|
/* If we come here the memory is valid (or BUF is NULL, which is
|
||||||
|
* a valid condition for the kernel syscall) and the kernel did not
|
||||||
return an EFAULT error. Return the value given by the kernel. */
|
return an EFAULT error. Return the value given by the kernel. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user