From 71b1dd06b6211b4a7ae733b714ff0d5bf0b52dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Mon, 16 Nov 2020 17:49:57 +0100 Subject: [PATCH] Fix a regression in closing a file descriptor if no --output was given --- time-1.9-Close-outfp-before-exec.patch | 20 ++++++++++++-------- time.spec | 6 +++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/time-1.9-Close-outfp-before-exec.patch b/time-1.9-Close-outfp-before-exec.patch index 4046335..3902bb6 100644 --- a/time-1.9-Close-outfp-before-exec.patch +++ b/time-1.9-Close-outfp-before-exec.patch @@ -1,30 +1,34 @@ -From 95b6dd923e176f0c42646e64cc9f22fb67a12b8f Mon Sep 17 00:00:00 2001 -From: Ed Santiago -Date: Fri, 6 Nov 2020 20:06:24 -0700 +From 6a5c4499aab677d19157c7adcf598d14267283c1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Mon, 16 Nov 2020 17:45:04 +0100 Subject: [PATCH] Close outfp before exec +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit When called with --outfile, we open an output file to which we log timing results. Close that descriptor in the child fork before exec'ing the process to be timed. -Signed-off-by: Ed Santiago +Reported-by: Ed Santiago +Signed-off-by: Petr Písař --- src/time.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/time.c b/src/time.c -index 53904c9..9c7d287 100644 +index f76265a..2f2b702 100644 --- a/src/time.c +++ b/src/time.c -@@ -813,6 +813,8 @@ run_command (cmd, resp) +@@ -738,6 +738,8 @@ run_command (cmd, resp) error (EXIT_CANCELED, errno, "cannot fork"); else if (pid == 0) { /* If child. */ -+ if (outfp != NULL) ++ if (outfp != stderr) + fclose(outfp); /* Don't cast execvp arguments; that causes errors on some systems, versus merely warnings if the cast is left off. */ execvp (cmd[0], cmd); -- -2.26.2 +2.25.4 diff --git a/time.spec b/time.spec index 17a6206..3d0b376 100644 --- a/time.spec +++ b/time.spec @@ -1,7 +1,7 @@ Summary: A GNU utility for monitoring a program's use of system resources Name: time Version: 1.9 -Release: 11%{?dist} +Release: 12%{?dist} # src/time.c: GPLv3+ # COPYING: GPLv3 text # doc/time.texi: GFDL @@ -96,6 +96,10 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir # time(1) manual page lives in man-pages package, bug #1612294. %changelog +* Mon Nov 16 2020 Petr Pisar - 1.9-12 +- Fix a regression in closing a file descriptor if no --output was given + (bug #1898138) + * Wed Nov 11 2020 Petr Pisar - 1.9-11 - Do not leak a file descriptor of the --output argument to a command