support: Also return fd when it is 0

This commit is contained in:
liqingqing_1229 2021-12-28 20:45:07 +08:00
parent 81b8721638
commit fcfb718ec7
2 changed files with 50 additions and 1 deletions

View File

@ -65,7 +65,7 @@
############################################################################## ##############################################################################
Name: glibc Name: glibc
Version: 2.34 Version: 2.34
Release: 38 Release: 39
Summary: The GNU libc libraries Summary: The GNU libc libraries
License: %{all_license} License: %{all_license}
URL: http://www.gnu.org/software/glibc/ URL: http://www.gnu.org/software/glibc/
@ -146,6 +146,7 @@ Patch59: io-Fix-ftw-internal-realloc-buffer-BZ-28126.patch
Patch60: Do-not-define-tgmath.h-fmaxmag-fminmag-macros-for-C2.patch Patch60: Do-not-define-tgmath.h-fmaxmag-fminmag-macros-for-C2.patch
Patch61: ld.so-Don-t-fill-the-DT_DEBUG-entry-in-ld.so-BZ-2812.patch Patch61: ld.so-Don-t-fill-the-DT_DEBUG-entry-in-ld.so-BZ-2812.patch
Patch62: elf-Replace-nsid-with-args.nsid-BZ-27609.patch Patch62: elf-Replace-nsid-with-args.nsid-BZ-27609.patch
Patch63: support-Also-return-fd-when-it-is-0.patch
Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch
Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch
@ -1342,6 +1343,9 @@ fi
%endif %endif
%changelog %changelog
* Tue Dec 28 2021 Qingqing Li <liqingqing3@huawei.com> - 2.34-39
- support: Also return fd when it is 0.
* Mon Dec 27 2021 Qingqing Li <liqingqing3@huawei.com> - 2.34-38 * Mon Dec 27 2021 Qingqing Li <liqingqing3@huawei.com> - 2.34-38
- elf: replace nsid with args.nsid [BZ #27609] - elf: replace nsid with args.nsid [BZ #27609]

View File

@ -0,0 +1,45 @@
From 27b6edbb090f736b101f569620d8ad0e7217ddf8 Mon Sep 17 00:00:00 2001
From: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Wed, 6 Oct 2021 21:48:35 +0530
Subject: [PATCH] support: Also return fd when it is 0
The fd validity check in open_dev_null checks if fd > 0, which would
lead to a leaked fd if it is == 0.
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
support/support-open-dev-null-range.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/support/support-open-dev-null-range.c b/support/support-open-dev-null-range.c
index 80d9dba..66a8504 100644
--- a/support/support-open-dev-null-range.c
+++ b/support/support-open-dev-null-range.c
@@ -40,16 +40,16 @@ increase_nofile (void)
static int
open_dev_null (int flags, mode_t mode)
{
- int fd = open64 ("/dev/null", flags, mode);
- if (fd > 0)
- return fd;
+ int fd = open64 ("/dev/null", flags, mode);
+ if (fd >= 0)
+ return fd;
- if (fd < 0 && errno != EMFILE)
- FAIL_EXIT1 ("open64 (\"/dev/null\", 0x%x, 0%o): %m", flags, mode);
+ if (fd < 0 && errno != EMFILE)
+ FAIL_EXIT1 ("open64 (\"/dev/null\", 0x%x, 0%o): %m", flags, mode);
- increase_nofile ();
+ increase_nofile ();
- return xopen ("/dev/null", flags, mode);
+ return xopen ("/dev/null", flags, mode);
}
struct range
--
1.8.3.1