]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
sh: Do not try to execute binary files as scripts.
authorjilles <jilles@FreeBSD.org>
Sat, 5 Feb 2011 12:54:59 +0000 (12:54 +0000)
committerjilles <jilles@FreeBSD.org>
Sat, 5 Feb 2011 12:54:59 +0000 (12:54 +0000)
commita81357fbe93ddb2be80ff1401450234c412c135d
tree999ded504b6f93787ff21b0740db2574608bc758
parentfa5090f1ddeff2b8b1efa2d3c21c5ba6b70e8fba
sh: Do not try to execute binary files as scripts.

If execve() returns an [ENOEXEC] error, check if the file is binary before
trying to execute it using sh. A file is considered binary if at least one
of the first 256 bytes is '\0'.

In particular, trying to execute ELF binaries for the wrong architecture now
fails with an "Exec format error" message instead of syntax errors and
potentially strange results.
bin/sh/exec.c
bin/sh/sh.1
tools/regression/bin/sh/errors/bad-binary1.126 [new file with mode: 0644]