mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
b3279b601e
I noticed that gdb could leak file descriptors coming from mkstemp. This patch fixes the problem by importing the gnulib mkostemp instead, and then changing gdb to pass O_CLOEXEC. A small gnulib patch was needed. This has already been accepted upstream. gdb/ChangeLog 2018-10-27 Tom Tromey <tom@tromey.com> * unittests/scoped_mmap-selftests.c (test_normal): Use gdb_mkostemp_cloexec. * unittests/scoped_fd-selftests.c (test_destroy, test_release): Use gdb_mkostemp_cloexec. * gnulib/aclocal-m4-deps.mk, gnulib/aclocal.m4, gnulib/config.in, gnulib/configure, gnulib/import/Makefile.am, gnulib/import/Makefile.in, gnulib/import/m4/gnulib-cache.m4, gnulib/import/m4/gnulib-comp.m4: Update. * gnulib/import/m4/mkostemp.m4: New file. * gnulib/import/m4/mkstemp.m4: Remove. * gnulib/import/mkostemp.c: New file. * gnulib/import/mkstemp.m4: Remove. * gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Remove mkstemp, add mkostemp. Apply new patch. * gnulib/import/stdlib.in.h: Apply patch. * gnulib/patches/0002-mkostemp-mkostemps-Fix-compilation-error-in-C-mode-o.patch: New file. * dwarf-index-write.c (write_psymtabs_to_index): Use gdb_mkostemp_cloexec. * common/filestuff.h (gdb_mkostemp_cloexec): New function.
39 lines
1.7 KiB
Diff
39 lines
1.7 KiB
Diff
From 6954995dd32ea98a1973df31f411f3996bb47dfb Mon Sep 17 00:00:00 2001
|
|
From: Tom Tromey <tom@tromey.com>
|
|
Date: Mon, 1 Oct 2018 14:57:45 -0600
|
|
Subject: [PATCH] mkostemp, mkostemps: Fix compilation error in C++ mode on Mac
|
|
OS X.
|
|
|
|
Attempting to use the mkostemp module in gdb caused a build failure
|
|
when using the C++ namespace feature, because mkostemp was not
|
|
declared. On OS X, mkostemp is declared in unistd.h, so this patch
|
|
extends the existing special case in stdlib.in.h to cover mkostemp and
|
|
mkostemps.
|
|
|
|
* lib/stdlib.in.h: Include <unistd.h> for mkostemp and mkostemps
|
|
on OS X.
|
|
---
|
|
ChangeLog | 6 ++++++
|
|
lib/stdlib.in.h | 3 ++-
|
|
2 files changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/gdb/gnulib/import/stdlib.in.h b/gdb/gnulib/import/stdlib.in.h
|
|
index db3253bd97..8f803a2ea3 100644
|
|
--- a/gdb/gnulib/import/stdlib.in.h
|
|
+++ b/gdb/gnulib/import/stdlib.in.h
|
|
@@ -87,9 +87,10 @@ struct random_data
|
|
# endif
|
|
#endif
|
|
|
|
-#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
|
|
+#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
|
|
/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
|
|
/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
|
|
+/* On Mac OS X 10.13, only <unistd.h> declares mkostemp and mkostemps. */
|
|
/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
|
|
/* But avoid namespace pollution on glibc systems and native Windows. */
|
|
# include <unistd.h>
|
|
--
|
|
2.19.0
|
|
|