65faa39b43
Upstream commit: 6548a9bdba95b3e1fcdbd85445342467e4b0cd4f - Avoid warning: overriding recipe for .../tst-ro-dynamic-mod.so - ld.so: Initialize bootstrap_map.l_ld_readonly [BZ #28340] - ld.so: Replace DL_RO_DYN_SECTION with dl_relocate_ld [BZ #28340] - Handle NULL input to malloc_usable_size [BZ #28506] - elf: Avoid deadlock between pthread_create and ctors [BZ #28357] - timex: Use 64-bit fields on 32-bit TIMESIZE=64 systems (BZ #28469) - y2038: Use a common definition for stat for sparc32 - elf: Replace nsid with args.nsid [BZ #27609] - S390: Add PCI_MIO and SIE HWCAPs - support: Also return fd when it is 0
42 lines
1.3 KiB
Diff
42 lines
1.3 KiB
Diff
commit 558168c78ea1eb8efb33959c1da9d6b5a997fd7b
|
|
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
|
Date: Wed Oct 6 21:48:35 2021 +0530
|
|
|
|
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>
|
|
(cherry picked from commit 27b6edbb090f736b101f569620d8ad0e7217ddf8)
|
|
|
|
diff --git a/support/support-open-dev-null-range.c b/support/support-open-dev-null-range.c
|
|
index 80d9dba50402ce12..66a850410557351b 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
|