* [PATCH] linux: wait4: Fix incorrect return value comparison
@ 2020-04-06 18:39 Alistair Francis
2020-04-06 19:00 ` Andreas Schwab
2020-04-06 19:19 ` Florian Weimer
0 siblings, 2 replies; 3+ messages in thread
From: Alistair Francis @ 2020-04-06 18:39 UTC (permalink / raw)
To: libc-alpha; +Cc: alistair23, Alistair Francis
Path 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.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
sysdeps/unix/sysv/linux/wait4.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/wait4.c b/sysdeps/unix/sysv/linux/wait4.c
index d14bd4da27..796691eb2b 100644
--- a/sysdeps/unix/sysv/linux/wait4.c
+++ b/sysdeps/unix/sysv/linux/wait4.c
@@ -32,10 +32,7 @@ __wait4_time64 (pid_t pid, int *stat_loc, int options, struct __rusage64 *usage)
struct __rusage32 usage32;
pid_t ret = SYSCALL_CANCEL (wait4, pid, stat_loc, options, &usage32);
- if (ret != 0)
- return ret;
-
- if (usage != NULL)
+ if (ret > 0 && usage != NULL)
rusage32_to_rusage64 (&usage32, usage);
return ret;
@@ -119,10 +116,8 @@ __wait4 (pid_t pid, int *stat_loc, int options, struct rusage *usage)
ret = __wait4_time64 (pid, stat_loc, options, &usage64);
- if (ret != 0)
- return ret;
-
- rusage64_to_rusage (&usage64, usage);
+ if (ret > 0 && usage != NULL)
+ rusage64_to_rusage (&usage64, usage);
return ret;
}
--
2.26.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] linux: wait4: Fix incorrect return value comparison
2020-04-06 18:39 [PATCH] linux: wait4: Fix incorrect return value comparison Alistair Francis
@ 2020-04-06 19:00 ` Andreas Schwab
2020-04-06 19:19 ` Florian Weimer
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2020-04-06 19:00 UTC (permalink / raw)
To: Alistair Francis via Libc-alpha; +Cc: Alistair Francis
On Apr 06 2020, Alistair Francis via Libc-alpha wrote:
> Path 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.
>
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
> sysdeps/unix/sysv/linux/wait4.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/wait4.c b/sysdeps/unix/sysv/linux/wait4.c
> index d14bd4da27..796691eb2b 100644
> --- a/sysdeps/unix/sysv/linux/wait4.c
> +++ b/sysdeps/unix/sysv/linux/wait4.c
> @@ -32,10 +32,7 @@ __wait4_time64 (pid_t pid, int *stat_loc, int options, struct __rusage64 *usage)
> struct __rusage32 usage32;
> pid_t ret = SYSCALL_CANCEL (wait4, pid, stat_loc, options, &usage32);
You should pass NULL if usage is NULL.
> @@ -119,10 +116,8 @@ __wait4 (pid_t pid, int *stat_loc, int options, struct rusage *usage)
>
> ret = __wait4_time64 (pid, stat_loc, options, &usage64);
Likewise.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] linux: wait4: Fix incorrect return value comparison
2020-04-06 18:39 [PATCH] linux: wait4: Fix incorrect return value comparison Alistair Francis
2020-04-06 19:00 ` Andreas Schwab
@ 2020-04-06 19:19 ` Florian Weimer
1 sibling, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2020-04-06 19:19 UTC (permalink / raw)
To: Alistair Francis via Libc-alpha; +Cc: Alistair Francis
* Alistair Francis via Libc-alpha:
> Path 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.
Would it make sense to add a test case?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-06 19:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 18:39 [PATCH] linux: wait4: Fix incorrect return value comparison Alistair Francis
2020-04-06 19:00 ` Andreas Schwab
2020-04-06 19:19 ` Florian Weimer
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).