[PATCH v2] binutils: objcopy/strip: fix preserving dates in ar archives
Alan Modra
amodra@gmail.com
Tue Sep 28 10:53:31 GMT 2021
On Tue, Sep 28, 2021 at 10:11:35AM +0200, Andreas Schwab wrote:
> On Sep 28 2021, Gleb Fotengauer-Malinovskiy wrote:
>
> > diff --git a/binutils/objcopy.c b/binutils/objcopy.c
> > index a6c2e0dcc26..0a3a9fb062e 100644
> > --- a/binutils/objcopy.c
> > +++ b/binutils/objcopy.c
> > @@ -3600,6 +3600,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
> >
> > if (preserve_dates)
> > {
> > + memset (&buf, 0, sizeof(buf));
>
> Style: space before paren.
There's another instance of this bug in ar.c too. Committed, thanks!
PR 28391
* ar.c (extract_file): Clear buf for preserve_dates.
* objcopy.c (copy_archive): Likewise.
diff --git a/binutils/ar.c b/binutils/ar.c
index 5d6976c7027..8885585ef75 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -1180,6 +1180,9 @@ extract_file (bfd *abfd)
bfd_size_type size;
struct stat buf;
+ if (preserve_dates)
+ memset (&buf, 0, sizeof (buf));
+
if (bfd_stat_arch_elt (abfd, &buf) != 0)
/* xgettext:c-format */
fatal (_("internal stat error on %s"), bfd_get_filename (abfd));
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index a6c2e0dcc26..fd7557fe433 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3600,6 +3600,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
if (preserve_dates)
{
+ memset (&buf, 0, sizeof (buf));
stat_status = bfd_stat_arch_elt (this_element, &buf);
if (stat_status != 0)
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list