objdump /tmp problems
Solar Designer
solar@openwall.com
Sun Jan 14 03:07:00 GMT 2001
Hi,
I am cross-posting this in an attempt to avoid duplicate work (which
I've caused with my original report).
On Sat, Jan 13, 2001 at 07:39:37PM +0000, Philip Blundell wrote:
> I think this patch should fix the problem with objdump mentioned in
> < http://sources.redhat.com/ml/bug-gnu-utils/2001-01/msg00076.html >. Another
Yes, thanks. However, as Marcus Meissner pointed out in reply to
that message (he didn't CC: bug-gnu-utils) the objdump problem has
already been fixed in a later version of binutils (I was checking
the 2.10 release). Sorry for that. :-(
Now that I've finally checked binutils 2.10.1.0.4, it does indeed
have the objdump and (from a look at the source only) the nlmconv
problems fixed:
2000-05-12 H.J. Lu <hjl@gnu.org>
* nlmconv.c (temp_filename): Removed.
* nlmconv.c (link_inputs): Use make_temp_file () instead of
choose_temp_base ().
* objdump.c (display_target_list): Likewise.
(display_info_table): Likewise.
Basically, it will still re-open the file without O_EXCL, but only
after first creating it safely. As the directory has the sticky bit
set, the file couldn't have been removed (hopefully, /tmp cleaners
are correct) and this is safe.
Your approach is nicer, though. I think I'll take the patch (with
some changes, see below) for a distribution.
The ar and objcopy problems (which are less significant) are still in
this new version (confirmed both with strace).
> way to deal with the issue would be to have objdump call _new_bfd directly --
> it doesn't actually want to do anything to the BFDs it creates in this
> situation, other than see if a target can be successfully selected.
>
> p.
>
> 2001-01-13 Philip Blundell <philb@gnu.org>
>
> * objdump.c (display_target_list): Avoid unsafe use of /tmp.
> (display_info_table): Likewise.
>
> Index: objdump.c
> ===================================================================
> RCS file: /cvs/src/src/binutils/objdump.c,v
> retrieving revision 1.32
> diff -u -p -u -r1.32 objdump.c
> --- objdump.c 2001/01/09 20:25:31 1.32
> +++ objdump.c 2001/01/13 19:37:28
> @@ -2645,14 +2645,14 @@ static void
> display_target_list ()
> {
> extern bfd_target *bfd_target_vector[];
> - char *dummy_name;
> int t;
>
> - dummy_name = make_temp_file (NULL);
> for (t = 0; bfd_target_vector[t]; t++)
> {
> + char dummy_name[] = "/tmp/XXXXXX";
The old code supported $TMPDIR, so I think this should do so as well
(perhaps another wrapper function should be added to choose-temp.c,
which will use $TMPDIR, but return an fd).
> + int fd = mkstemp(dummy_name);
I believe mkstemp() isn't sufficiently portable for use in binutils,
and that's why there's mkstemps() in libiberty.
Actually, I would prefer a configure check for mkstemp(), as several
systems (currently, the *BSD's) have better implementations in libc.
--
/sd
More information about the Binutils
mailing list