Here is Debian bug report against binutils: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=288001 From: Jari <jari.aalto@cante.net> To: Debian Bug Tracking System <submit@bugs.debian.org> Subject: binutils: [source build] warning: the use of `mktemp' is dangerous, better use `mkstemp' Date: Fri, 31 Dec 2004 17:46:40 +0200 Package: binutils Version: 2.15-5 Severity: minor Compiling from source gives following warnings that could be corrected. bucomm.o(.text+0xa99): In function `make_tempname': /tmp/bucomm.c:425: warning: the use of `mktemp' is dangerous, better use `mkstemp'
Created attachment 1135 [details] Patch to replace mktemp with mkstemp
Hi Mohammed, This is a known problem, but your fix will not work. For a discussion of why, please see this thread: http://sourceware.org/ml/binutils/2003-07/msg00009.html Cheers Nick
Created attachment 1360 [details] new mkstemp/mkdtemp patch I made this patch from OpenBSD-cvs Binutils source, and added some autoconf stuff so mktemp(3) will be used if the system does not have mkstemp/mkdtemp(3). This patch should allow systems with mkstemp/mkdtemp to use them while staying portable to systems without mkstemp.
Reopen bug with proposed patch (request for comments).
Hi Robert, Thanks for the patch. I have tidied it up slightly and applied it along with this ChangeLog entry. Cheers Nick binutils/ChangeLog 2006-10-13 Robert Connolly <robert@linuxfromscratch.org> PR binutils/2876 * configure.in: Check for the mkstemp and mkdtemp functions. * configure: Regenerate. * config.in (HAVE_MKDTEMP): New potential define. (MAKE_MKSTEMP): Likewise. * bucomm.c (make_tempname): Use mkstemp if it is available. (make_tempdir): New function: Create a temporary directory using mkdtemp, if it is available. * bucomm.h (make_tempdir): New prototype. * objcopy.c (copy_archive): Use make_tempdir if it is available. (strip_main): Produce an warning message if a temporary file could not be created. (copy_main): Likewise. * ar.c (write_archive): Likewise.