New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdenv: Improve ELF detection for isELF #47244
Conversation
pkgs/stdenv/generic/setup.sh
Outdated
@@ -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" = 'ELF' ]; then return 0; else return 1; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that there is a 0x7F character here, GitHub just doesn't show it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I'll probably change this to $'\177ELF
.
Failure on x86_64-darwin (full log) Attempted: stdenv Partial log (click to expand)
|
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>
c6d5923
to
944379a
Compare
Timed out, unknown build status on x86_64-linux (full log) Attempted: stdenv Partial log (click to expand)
|
Failure on x86_64-darwin (full log) Attempted: stdenv Partial log (click to expand)
|
Is there something that motivated this? Just curious, especially since this and #47249 were submitted so close to each other. |
Timed out, unknown build status on x86_64-linux (full log) Attempted: stdenv Partial log (click to expand)
|
Timed out, unknown build status on aarch64-linux (full log) Attempted: stdenv Partial log (click to expand)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
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: #47244
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:
So instead, we're now doing a precise match on
\x7fELF
.