Fix some #! misparsing in check_interpreter
* exec/exec.c: Do not include ctype.h, as the kernel does not care about the locale. (check_interpreter): Treat only spaces and tabs as white space. Do not inspect more bytes than were read. Although the resulting code does not exactly match what the Android kernel does, it’s closer than what it was before.
This commit is contained in:
parent
58a44b6ac3
commit
e0b027d121
1 changed files with 5 additions and 5 deletions
10
exec/exec.c
10
exec/exec.c
|
@ -24,7 +24,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sys/ptrace.h>
|
||||
|
@ -116,11 +115,11 @@ check_interpreter (const char *name, int fd, const char **extra)
|
|||
|
||||
/* Strip leading whitespace. */
|
||||
start = buffer;
|
||||
while (*start && ((unsigned char) *start) < 128 && isspace (*start))
|
||||
while (start < buffer + rc && (*start == ' ' || *start == '\t'))
|
||||
++start;
|
||||
|
||||
/* Look for a newline character. */
|
||||
end = memchr (start, '\n', rc);
|
||||
end = memchr (start, '\n', buffer + rc - start);
|
||||
|
||||
if (!end)
|
||||
goto fail;
|
||||
|
@ -130,11 +129,12 @@ check_interpreter (const char *name, int fd, const char **extra)
|
|||
*end = '\0';
|
||||
|
||||
/* Now look for any whitespace characters. */
|
||||
ws = strchr (start, ' ');
|
||||
for (ws = start; *ws && *ws != ' ' && *ws != '\t'; ws++)
|
||||
continue;
|
||||
|
||||
/* If there's no whitespace, return the entire start. */
|
||||
|
||||
if (!ws)
|
||||
if (!*ws)
|
||||
{
|
||||
if (lseek (fd, 0, SEEK_SET))
|
||||
goto fail;
|
||||
|
|
Loading…
Add table
Reference in a new issue