stdenv: Improve ELF detection for isELF
The isELF function only checks whether ELF is contained within the first 4 bytes of the file, which is a bit fuzzy and will also return successful if it's a text file starting with ELF, for example: ELF headers ----------- Some text here about ELF headers... So instead, we're now doing a precise match on \x7fELF. Signed-off-by: aszlig <aszlig@nix.build> Acked-by: @Ericson2314 Closes: https://github.com/NixOS/nixpkgs/pull/47244
This commit is contained in:
parent
2b4b7d4ef3
commit
b25b6e0c75
1 changed files with 1 additions and 1 deletions
|
@ -211,7 +211,7 @@ isELF() {
|
|||
exec {fd}< "$fn"
|
||||
read -r -n 4 -u "$fd" magic
|
||||
exec {fd}<&-
|
||||
if [[ "$magic" =~ ELF ]]; then return 0; else return 1; fi
|
||||
if [ "$magic" = $'\177ELF' ]; then return 0; else return 1; fi
|
||||
}
|
||||
|
||||
# Return success if the specified file is a script (i.e. starts with
|
||||
|
|
Loading…
Reference in a new issue