aboutsummaryrefslogtreecommitdiff
path: root/binutils/elfedit.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-03-14 11:50:22 +1030
committerAlan Modra <amodra@gmail.com>2020-03-14 17:24:19 +1030
commit780f96aed2b4db1014e8fa2b50118676d8af0e46 (patch)
tree06cceab0c41b0978c51811e1c280733045ee1488 /binutils/elfedit.c
parentf761cb13a903da6a5a1b3f9a5cb984600124ac31 (diff)
downloadbinutils-780f96aed2b4db1014e8fa2b50118676d8af0e46.zip
binutils-780f96aed2b4db1014e8fa2b50118676d8af0e46.tar.gz
binutils-780f96aed2b4db1014e8fa2b50118676d8af0e46.tar.bz2
readelf large memory allocation
* elfcomm.h (setup_archive): Update prototype. * elfcomm.c (setup_archive): Add file_size parameter and sanity check longnames_size. (setup_nested_archive): Get file size and pass to setup_archive. * elfedit.c (process_archive): Likewise. * readelf.c (process_archive): Pass filedata->file_size to setup_archive.
Diffstat (limited to 'binutils/elfedit.c')
-rw-r--r--binutils/elfedit.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/binutils/elfedit.c b/binutils/elfedit.c
index 3a14c60..d0e4e95 100644
--- a/binutils/elfedit.c
+++ b/binutils/elfedit.c
@@ -541,6 +541,7 @@ process_archive (const char * file_name, FILE * file,
struct archive_info nested_arch;
size_t got;
int ret;
+ struct stat statbuf;
/* The ARCH structure is used to hold information about this archive. */
arch.file_name = NULL;
@@ -558,7 +559,9 @@ process_archive (const char * file_name, FILE * file,
nested_arch.sym_table = NULL;
nested_arch.longnames = NULL;
- if (setup_archive (&arch, file_name, file, is_thin_archive, FALSE) != 0)
+ if (fstat (fileno (file), &statbuf) < 0
+ || setup_archive (&arch, file_name, file, statbuf.st_size,
+ is_thin_archive, FALSE) != 0)
{
ret = 1;
goto out;