aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-09-15 10:22:13 +0930
committerAlan Modra <amodra@gmail.com>2017-09-15 10:36:40 +0930
commit21d0a60620b306d6471ddedff04ac23912596cc6 (patch)
tree3f6bacef41f452a3947e289c61d99a2d379139e9 /bfd
parentcc3e190059e6c817203049a52c8bc4b37b58ce74 (diff)
downloadgdb-21d0a60620b306d6471ddedff04ac23912596cc6.zip
gdb-21d0a60620b306d6471ddedff04ac23912596cc6.tar.gz
gdb-21d0a60620b306d6471ddedff04ac23912596cc6.tar.bz2
Error when 32-bit ar tries to handle 4G or larger files
We used to silently truncate the size returned by stat() to 32 bits. While it is possible to make binutils handle a 64-bit off_t on a 32-bit host, to me the effort needed doesn't seem worth the benefit. Instead, error if we truncate the size. I've written the test the way I have to avoid a signed/unsigned warning. PR 22116 * archive.c (bfd_ar_hdr_from_filesystem): Detect when status.st_size overflows bfd_size_type.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/archive.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e4df74d..5f6b423 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-15 Alan Modra <amodra@gmail.com>
+
+ PR 22116
+ * archive.c (bfd_ar_hdr_from_filesystem): Detect when status.st_size
+ overflows bfd_size_type.
+
2017-09-14 H.J. Lu <hongjiu.lu@intel.com>
PR ld/22135
diff --git a/bfd/archive.c b/bfd/archive.c
index 885bf48..3ce3f9e 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1980,6 +1980,12 @@ bfd_ar_hdr_from_filesystem (bfd *abfd, const char *filename, bfd *member)
status.st_gid);
_bfd_ar_spacepad (hdr->ar_mode, sizeof (hdr->ar_mode), "%-8lo",
status.st_mode);
+ if (status.st_size - (bfd_size_type) status.st_size != 0)
+ {
+ bfd_set_error (bfd_error_file_too_big);
+ free (ared);
+ return NULL;
+ }
if (!_bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), status.st_size))
{
free (ared);