Commit 2aaedef4 authored by Sergey Lyubka's avatar Sergey Lyubka

Trimming whitespaces properly in windows CGI interpreter name

parent b437d567
...@@ -1243,6 +1243,13 @@ static int kill(pid_t pid, int sig_num) { ...@@ -1243,6 +1243,13 @@ static int kill(pid_t pid, int sig_num) {
return 0; return 0;
} }
static void trim_trailing_whitespaces(char *s) {
char *e = s + strlen(s) - 1;
while (e > s && isspace(* (unsigned char *) e)) {
*e-- = '\0';
}
}
static pid_t spawn_process(struct mg_connection *conn, const char *prog, static pid_t spawn_process(struct mg_connection *conn, const char *prog,
char *envblk, char *envp[], int fd_stdin, char *envblk, char *envp[], int fd_stdin,
int fd_stdout, const char *dir) { int fd_stdout, const char *dir) {
...@@ -1279,10 +1286,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog, ...@@ -1279,10 +1286,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
} }
if (buf[0] == '#' && buf[1] == '!') { if (buf[0] == '#' && buf[1] == '!') {
// Trim whitespace in interpreter name trim_trailing_whitespaces(buf + 2);
for (p = buf + 2; *p != '\0' && isspace(* (unsigned char *) p); )
p++;
*p = '\0';
} else { } else {
buf[2] = '\0'; buf[2] = '\0';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment