auto-patchelf: catch OSError for compressed ELF parsing failures (#519339)

This commit is contained in:
Ryan Hendrickson 2026-06-30 21:18:28 +00:00 committed by GitHub
commit 92ff23e587
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
import errno
import os
import pprint
import subprocess
@ -195,6 +196,12 @@ def populate_cache(initial: list[Path], recursive: bool =False) -> None:
except ELFError:
# Not an ELF file in the right format
pass
except OSError as e:
if e.errno == errno.EINVAL:
# pyelftools can raise EINVAL for certain compressed sections.
pass
else:
raise
def find_dependency(soname: str, soarch: str, soabi: str) -> Optional[Path]:
@ -343,6 +350,10 @@ def auto_patchelf_file(logger: Logger, path: Path, runtime_deps: list[Path], app
except ELFError:
return []
except OSError as e:
if e.errno == errno.EINVAL:
return []
raise
# these platforms are packaged in nixpkgs with ld.so in a separate derivation
# than libc.so and friends. keep_libc is mandatory.