Bug 2876 - [Build] "Dangerous" mktemp warning
Summary: [Build] "Dangerous" mktemp warning
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.18
: P2 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-04 18:25 UTC by Mohammed Adnène Trojette
Modified: 2006-10-13 10:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Patch to replace mktemp with mkstemp (228 bytes, patch)
2006-07-04 18:26 UTC, Mohammed Adnène Trojette
Details | Diff
new mkstemp/mkdtemp patch (2.97 KB, patch)
2006-10-09 12:22 UTC, Robert Connolly
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mohammed Adnène Trojette 2006-07-04 18:25:23 UTC
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'
Comment 1 Mohammed Adnène Trojette 2006-07-04 18:26:05 UTC
Created attachment 1135 [details]
Patch to replace mktemp with mkstemp
Comment 2 Nick Clifton 2006-07-06 11:06:59 UTC
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
Comment 3 Robert Connolly 2006-10-09 12:22:13 UTC
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.
Comment 4 Robert Connolly 2006-10-11 06:27:40 UTC
Reopen bug with proposed patch (request for comments).
Comment 5 Nick Clifton 2006-10-13 10:14:10 UTC
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.