Closed ribes96 closed 1 month ago
Hi I'm running a CGI server using libwebsockets on linux I find the value of all the CGI environment variables is starting with an equal sign =
=
PATH==/bin:/usr/bin:/usr/local/bin:/var/www/cgi-bin REQUEST_METHOD==GET QUERY_STRING== REQUEST_URI==/cgi/a/b/c PATH_INFO==/a/b/c HTTP_HOST==ntime HTTP_USER_AGENT==Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0 HTTP_ACCEPT==text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,/;q=0.8 HTTP_ACCEPT_ENCODING==gzip, deflate SCRIPT_PATH==/usr/bin/my-cgi-script.sh SERVER_SOFTWARE==lws
Seems the following code is wrong:
while (i->env_array[m]){ 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++; }
And the fix seems trivial: just add a ++p in setenv:
++p
while (i->env_array[m]){ 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++; }
What version of lws is this?
Sorry This is libwebsockets-4.3.3, and also current main commit
main
Thanks, this is pushed on main and v4-3-stable
Hi I'm running a CGI server using libwebsockets on linux I find the value of all the CGI environment variables is starting with an equal sign
=
Seems the following code is wrong:
And the fix seems trivial: just add a
++p
in setenv: