aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiƩbaud Weksteen <tweek@google.com>2021-01-25 15:33:09 +0100
committerThiƩbaud Weksteen <tweek@google.com>2021-01-25 15:33:09 +0100
commit108d7544eff3aefb0f12f1d3d18771b186422d2f (patch)
treef0fe46078487689c2f01a2a9eae64c3f890e97ff
parentc41086cfcaa0ba611648edfd972a50735aa1d363 (diff)
downloadbloaty-108d7544eff3aefb0f12f1d3d18771b186422d2f.tar.gz
Fix parsing of archives
ar files require the data to be 2-bytes aligned. Update the Consume method to read an even number of bytes. The consumption of the header is unaltered as it is 60 bytes long.
-rw-r--r--src/elf.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/elf.cc b/src/elf.cc
index 1f9efa5..7ada956 100644
--- a/src/elf.cc
+++ b/src/elf.cc
@@ -655,6 +655,7 @@ class ArFile {
private:
string_view Consume(size_t n) {
+ n = (n % 2 == 0 ? n : n + 1);
if (remaining_.size() < n) {
THROW("premature end of file");
}