* [RFA] archive.c, bsd_write_armap, fail if stat fails
@ 2011-03-03 18:46 Michael Snyder
2011-03-03 22:25 ` Alan Modra
2011-03-04 12:59 ` Nick Clifton
0 siblings, 2 replies; 6+ messages in thread
From: Michael Snyder @ 2011-03-03 18:46 UTC (permalink / raw)
To: nickc, rth, bug-binutils, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 41 bytes --]
Perhaps nit-picky -- what do you think?
[-- Attachment #2: archive.txt --]
[-- Type: text/plain, Size: 797 bytes --]
2011-03-03 Michael Snyder <msnyder@vmware.com>
* archive.c (bsd_write_armap): Fail if stat fails.
Index: archive.c
===================================================================
RCS file: /cvs/src/src/bfd/archive.c,v
retrieving revision 1.72
diff -u -p -u -p -r1.72 archive.c
--- archive.c 28 Feb 2011 18:30:16 -0000 1.72
+++ archive.c 3 Mar 2011 18:40:54 -0000
@@ -2304,7 +2304,11 @@ bsd_write_armap (bfd *arch,
firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG;
- stat (arch->filename, &statbuf);
+ if (stat (arch->filename, &statbuf) != 0)
+ {
+ bfd_set_error (bfd_error_system_call);
+ return FALSE;
+ }
if ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0)
{
/* Remember the timestamp, to keep it holy. But fudge it a little. */
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [RFA] archive.c, bsd_write_armap, fail if stat fails 2011-03-03 18:46 [RFA] archive.c, bsd_write_armap, fail if stat fails Michael Snyder @ 2011-03-03 22:25 ` Alan Modra 2011-03-03 23:39 ` Michael Snyder 2011-03-04 12:59 ` Nick Clifton 1 sibling, 1 reply; 6+ messages in thread From: Alan Modra @ 2011-03-03 22:25 UTC (permalink / raw) To: Michael Snyder; +Cc: nickc, rth, bug-binutils, gdb-patches On Thu, Mar 03, 2011 at 10:46:09AM -0800, Michael Snyder wrote: > * archive.c (bsd_write_armap): Fail if stat fails. I think it would be better to just set the timestamp to zero if stat fails. There is precedent for this, eg. opncls.c:_maybe_make_executable. -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] archive.c, bsd_write_armap, fail if stat fails 2011-03-03 22:25 ` Alan Modra @ 2011-03-03 23:39 ` Michael Snyder 2011-03-04 1:22 ` Alan Modra 2011-03-04 13:00 ` Nick Clifton 0 siblings, 2 replies; 6+ messages in thread From: Michael Snyder @ 2011-03-03 23:39 UTC (permalink / raw) To: Michael Snyder, nickc, rth, bug-binutils, gdb-patches Alan Modra wrote: > On Thu, Mar 03, 2011 at 10:46:09AM -0800, Michael Snyder wrote: >> * archive.c (bsd_write_armap): Fail if stat fails. > > I think it would be better to just set the timestamp to zero if stat > fails. There is precedent for this, eg. opncls.c:_maybe_make_executable. > Err, can I leave that to you? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] archive.c, bsd_write_armap, fail if stat fails 2011-03-03 23:39 ` Michael Snyder @ 2011-03-04 1:22 ` Alan Modra 2011-03-04 13:00 ` Nick Clifton 1 sibling, 0 replies; 6+ messages in thread From: Alan Modra @ 2011-03-04 1:22 UTC (permalink / raw) To: Michael Snyder; +Cc: binutils, gdb-patches On Thu, Mar 03, 2011 at 03:39:18PM -0800, Michael Snyder wrote: > Alan Modra wrote: > >On Thu, Mar 03, 2011 at 10:46:09AM -0800, Michael Snyder wrote: > >> * archive.c (bsd_write_armap): Fail if stat fails. > > > >I think it would be better to just set the timestamp to zero if stat > >fails. There is precedent for this, eg. opncls.c:_maybe_make_executable. > > > Err, can I leave that to you? * archive.c (bsd_write_armap): Don't call stat in deterministic mode, and don't use st_mtime if stat returns error. Index: bfd/archive.c =================================================================== RCS file: /cvs/src/src/bfd/archive.c,v retrieving revision 1.72 diff -u -p -r1.72 archive.c --- bfd/archive.c 28 Feb 2011 18:30:16 -0000 1.72 +++ bfd/archive.c 4 Mar 2011 00:52:22 -0000 @@ -2299,31 +2299,28 @@ bsd_write_armap (bfd *arch, bfd_byte temp[4]; unsigned int count; struct ar_hdr hdr; - struct stat statbuf; long uid, gid; firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG; - stat (arch->filename, &statbuf); + /* If deterministic, we use 0 as the timestamp in the map. + Some linkers may require that the archive filesystem modification + time is less than (or near to) the archive map timestamp. Those + linkers should not be used with deterministic mode. (GNU ld and + Gold do not have this restriction.) */ + bfd_ardata (arch)->armap_timestamp = 0; + uid = 0; + gid = 0; if ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0) { - /* Remember the timestamp, to keep it holy. But fudge it a little. */ - bfd_ardata (arch)->armap_timestamp = (statbuf.st_mtime - + ARMAP_TIME_OFFSET); + struct stat statbuf; + + if (stat (arch->filename, &statbuf) == 0) + bfd_ardata (arch)->armap_timestamp = (statbuf.st_mtime + + ARMAP_TIME_OFFSET); uid = getuid(); gid = getgid(); } - else - { - /* If deterministic, we use 0 as the timestamp in the map. - Some linkers may require that the archive filesystem modification - time is less than (or near to) the archive map timestamp. Those - linkers should not be used with deterministic mode. (GNU ld and - Gold do not have this restriction.) */ - bfd_ardata (arch)->armap_timestamp = 0; - uid = 0; - gid = 0; - } memset (&hdr, ' ', sizeof (struct ar_hdr)); memcpy (hdr.ar_name, RANLIBMAG, strlen (RANLIBMAG)); -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] archive.c, bsd_write_armap, fail if stat fails 2011-03-03 23:39 ` Michael Snyder 2011-03-04 1:22 ` Alan Modra @ 2011-03-04 13:00 ` Nick Clifton 1 sibling, 0 replies; 6+ messages in thread From: Nick Clifton @ 2011-03-04 13:00 UTC (permalink / raw) To: Michael Snyder; +Cc: rth, bug-binutils, gdb-patches Hi Miachael, > Alan Modra wrote: >> On Thu, Mar 03, 2011 at 10:46:09AM -0800, Michael Snyder wrote: >>> * archive.c (bsd_write_armap): Fail if stat fails. >> >> I think it would be better to just set the timestamp to zero if stat >> fails. There is precedent for this, eg. opncls.c:_maybe_make_executable. > > Err, can I leave that to you? Oops - I should have read all my emails first... ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] archive.c, bsd_write_armap, fail if stat fails 2011-03-03 18:46 [RFA] archive.c, bsd_write_armap, fail if stat fails Michael Snyder 2011-03-03 22:25 ` Alan Modra @ 2011-03-04 12:59 ` Nick Clifton 1 sibling, 0 replies; 6+ messages in thread From: Nick Clifton @ 2011-03-04 12:59 UTC (permalink / raw) To: Michael Snyder; +Cc: rth, bug-binutils, gdb-patches Hi Michael. > Perhaps nit-picky -- what do you think? > 2011-03-03 Michael Snyder <msnyder@vmware.com> > > * archive.c (bsd_write_armap): Fail if stat fails. I am all for paranoid programming - please apply. Cheers Nick ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-03-04 13:00 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-03-03 18:46 [RFA] archive.c, bsd_write_armap, fail if stat fails Michael Snyder 2011-03-03 22:25 ` Alan Modra 2011-03-03 23:39 ` Michael Snyder 2011-03-04 1:22 ` Alan Modra 2011-03-04 13:00 ` Nick Clifton 2011-03-04 12:59 ` Nick Clifton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox