aboutsummaryrefslogtreecommitdiffstats
path: root/exec/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'exec/exec.c')
-rw-r--r--exec/exec.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/exec/exec.c b/exec/exec.c
index 775a8b06b96..f31c9a89744 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -24,7 +24,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
24#include <fcntl.h> 24#include <fcntl.h>
25#include <assert.h> 25#include <assert.h>
26#include <string.h> 26#include <string.h>
27#include <ctype.h>
28#include <stdlib.h> 27#include <stdlib.h>
29 28
30#include <sys/ptrace.h> 29#include <sys/ptrace.h>
@@ -116,11 +115,11 @@ check_interpreter (const char *name, int fd, const char **extra)
116 115
117 /* Strip leading whitespace. */ 116 /* Strip leading whitespace. */
118 start = buffer; 117 start = buffer;
119 while (*start && ((unsigned char) *start) < 128 && isspace (*start)) 118 while (start < buffer + rc && (*start == ' ' || *start == '\t'))
120 ++start; 119 ++start;
121 120
122 /* Look for a newline character. */ 121 /* Look for a newline character. */
123 end = memchr (start, '\n', rc); 122 end = memchr (start, '\n', buffer + rc - start);
124 123
125 if (!end) 124 if (!end)
126 goto fail; 125 goto fail;
@@ -130,11 +129,12 @@ check_interpreter (const char *name, int fd, const char **extra)
130 *end = '\0'; 129 *end = '\0';
131 130
132 /* Now look for any whitespace characters. */ 131 /* Now look for any whitespace characters. */
133 ws = strchr (start, ' '); 132 for (ws = start; *ws && *ws != ' ' && *ws != '\t'; ws++)
133 continue;
134 134
135 /* If there's no whitespace, return the entire start. */ 135 /* If there's no whitespace, return the entire start. */
136 136
137 if (!ws) 137 if (!*ws)
138 { 138 {
139 if (lseek (fd, 0, SEEK_SET)) 139 if (lseek (fd, 0, SEEK_SET))
140 goto fail; 140 goto fail;