1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-08 18:02:05 +03:00

getdeps: dyndeps: gracefully handle empty files

Summary:
Don't error out if we can't read the ELF/MACH-O header; just treat
it is not an object.

Reviewed By: chadaustin, simpkins

Differential Revision: D19253434

fbshipit-source-id: c5ecc7f0bc7a20e2611b7e2ff754355155f095da
This commit is contained in:
Wez Furlong
2020-01-09 07:29:00 -08:00
committed by Facebook Github Bot
parent 9733a79287
commit 31d721301c

View File

@@ -251,7 +251,10 @@ class MachDeps(DepBase):
with open(objfile, "rb") as f:
# mach stores the magic number in native endianness,
# so unpack as native here and compare
magic = unpack("I", f.read(4))[0]
header = f.read(4)
if len(header) != 4:
return False
magic = unpack("I", header)[0]
return magic == MACH_MAGIC
def list_dynamic_deps(self, objfile):