Skip to content

Commit

Permalink
Make sure we don't use binary on EmptyType with lief (#4900)
Browse files Browse the repository at this point in the history
Co-authored-by: Jannis Leidel <jannis@leidel.info>
  • Loading branch information
katietz and jezdez authored Jun 6, 2023
1 parent e4cc6b0 commit ef12b93
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
12 changes: 10 additions & 2 deletions conda_build/os_utils/liefldd.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ def get_runpaths_or_rpaths_raw(file):

def set_rpath(old_matching, new_rpath, file):
binary = ensure_binary(file)
if not binary:
return
if binary.format == lief.EXE_FORMATS.ELF and (
binary.type == lief.ELF.ELF_CLASS.CLASS32
or binary.type == lief.ELF.ELF_CLASS.CLASS64
Expand Down Expand Up @@ -343,7 +345,9 @@ def _get_path_dirs(prefix):

def get_uniqueness_key(file):
binary = ensure_binary(file)
if binary.format == lief.EXE_FORMATS.MACHO:
if not binary:
return lief.EXE_FORMATS.UNKNOWN
elif binary.format == lief.EXE_FORMATS.MACHO:
return binary.name
elif binary.format == lief.EXE_FORMATS.ELF and ( # noqa
binary.type == lief.ELF.ELF_CLASS.CLASS32
Expand Down Expand Up @@ -463,7 +467,9 @@ def inspect_linkages_lief(
sysroot = _trim_sysroot(sysroot)

default_paths = []
if binary.format == lief.EXE_FORMATS.ELF:
if not binary:
default_paths = []
elif binary.format == lief.EXE_FORMATS.ELF:
if binary.type == lief.ELF.ELF_CLASS.CLASS64:
default_paths = [
"$SYSROOT/lib64",
Expand Down Expand Up @@ -491,6 +497,8 @@ def inspect_linkages_lief(
filename2 = element[0]
binary = element[1]
uniqueness_key = get_uniqueness_key(binary)
if not binary:
continue
if uniqueness_key not in already_seen:
parent_exe_dirname = None
if binary.format == lief.EXE_FORMATS.PE:
Expand Down
19 changes: 19 additions & 0 deletions news/4787-fix-leaf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Fixed handling of unknown binaries with newer (py)lief versions. (#4900)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>

0 comments on commit ef12b93

Please sign in to comment.