mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
spawn: in discrete env setting case do it readonly
OSX changed to blow a segfault on write to .rodata, exposing that we're dropping a NUL in what can be .rodata to set the environment manually. We don't do this on Linux typically because we take the code path where execvpe() is available to do the env for us. Adapt the code to treat it as const, and underscore it by changing its type to be const char ** in the info struct.
This commit is contained in:
parent
8eef15f3aa
commit
22e6d5212b
3 changed files with 9 additions and 6 deletions
|
@ -895,7 +895,7 @@ struct lws_spawn_piped_info {
|
|||
struct lws *opt_parent;
|
||||
|
||||
const char * const *exec_array;
|
||||
char **env_array;
|
||||
const char **env_array;
|
||||
const char *protocol_name;
|
||||
const char *chroot_path;
|
||||
const char *wd;
|
||||
|
|
|
@ -528,16 +528,19 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)
|
|||
#if defined(__linux__) || defined(__APPLE__)
|
||||
m = 0;
|
||||
while (i->env_array[m]){
|
||||
char *p = strchr(i->env_array[m], '=');
|
||||
*p++ = '\0';
|
||||
setenv(i->env_array[m], p, 1);
|
||||
const char *p = strchr(i->env_array[m], '=');
|
||||
int naml = lws_ptr_diff(p, i->env_array[m]);
|
||||
char enam[32];
|
||||
|
||||
lws_strnncpy(enam, i->env_array[m], naml, sizeof(enam));
|
||||
setenv(enam, p, 1);
|
||||
m++;
|
||||
}
|
||||
#endif
|
||||
execvp(i->exec_array[0], (char * const *)&i->exec_array[0]);
|
||||
#else
|
||||
execvpe(i->exec_array[0], (char * const *)&i->exec_array[0],
|
||||
&i->env_array[0]);
|
||||
(char **)&i->env_array[0]);
|
||||
#endif
|
||||
|
||||
lwsl_err("%s: child exec of %s failed %d\n", __func__, i->exec_array[0],
|
||||
|
|
|
@ -385,7 +385,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array,
|
|||
#endif
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.env_array = env_array;
|
||||
info.env_array = (const char **)env_array;
|
||||
info.exec_array = exec_array;
|
||||
info.max_log_lines = 20000;
|
||||
info.opt_parent = wsi;
|
||||
|
|
Loading…
Add table
Reference in a new issue