public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] linux: wait4: Fix incorrect return value comparison
@ 2020-04-14 16:25 Alistair Francis
0 siblings, 0 replies; only message in thread
From: Alistair Francis @ 2020-04-14 16:25 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=00515ea3a15703a3d196c1d1bd372214abc990ad
commit 00515ea3a15703a3d196c1d1bd372214abc990ad
Author: Alistair Francis <alistair.francis@wdc.com>
Date: Mon Apr 6 10:56:26 2020 -0700
linux: wait4: Fix incorrect return value comparison
Patch 600f00b "linux: Use long time_t for wait4/getrusage" introduced
two bugs:
- The usage32 struct was set if the wait4 syscall had an error.
- For 32-bit systems the usage struct was set even if it was specified
as NULL.
This patch fixes the two issues.
Diff:
---
sysdeps/unix/sysv/linux/wait4.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/wait4.c b/sysdeps/unix/sysv/linux/wait4.c
index d14bd4da27..44c55f60fe 100644
--- a/sysdeps/unix/sysv/linux/wait4.c
+++ b/sysdeps/unix/sysv/linux/wait4.c
@@ -29,13 +29,13 @@ __wait4_time64 (pid_t pid, int *stat_loc, int options, struct __rusage64 *usage)
# if __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64
return SYSCALL_CANCEL (wait4, pid, stat_loc, options, usage);
# else
+ pid_t ret;
struct __rusage32 usage32;
- pid_t ret = SYSCALL_CANCEL (wait4, pid, stat_loc, options, &usage32);
- if (ret != 0)
- return ret;
+ ret = SYSCALL_CANCEL (wait4, pid, stat_loc, options,
+ usage != NULL ? &usage32 : NULL);
- if (usage != NULL)
+ if (ret > 0 && usage != NULL)
rusage32_to_rusage64 (&usage32, usage);
return ret;
@@ -114,15 +114,14 @@ libc_hidden_def (__wait4_time64)
pid_t
__wait4 (pid_t pid, int *stat_loc, int options, struct rusage *usage)
{
- pid_t ret ;
+ pid_t ret;
struct __rusage64 usage64;
- ret = __wait4_time64 (pid, stat_loc, options, &usage64);
+ ret = __wait4_time64 (pid, stat_loc, options,
+ usage != NULL ? &usage64 : NULL);
- if (ret != 0)
- return ret;
-
- rusage64_to_rusage (&usage64, usage);
+ if (ret > 0 && usage != 0)
+ rusage64_to_rusage (&usage64, usage);
return ret;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-14 16:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 16:25 [glibc] linux: wait4: Fix incorrect return value comparison Alistair Francis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).