Commit c125c65e authored by Wez Furlong's avatar Wez Furlong Committed by Facebook Github Bot

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
parent 821088c5
...@@ -251,7 +251,10 @@ class MachDeps(DepBase): ...@@ -251,7 +251,10 @@ class MachDeps(DepBase):
with open(objfile, "rb") as f: with open(objfile, "rb") as f:
# mach stores the magic number in native endianness, # mach stores the magic number in native endianness,
# so unpack as native here and compare # 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 return magic == MACH_MAGIC
def list_dynamic_deps(self, objfile): def list_dynamic_deps(self, objfile):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment