mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-18 19:31:02 +00:00
Fix corner case in preparing cgi env
`path_info` was dereferenced without checking for NULL, and a few lines below, it was checked for NULL. CL: none PUBLISHED_FROM=9f14dc68c152b9b1119b276f047686d831bace38
This commit is contained in:
1 parent
8e366916d5
commit
ce8657f12f
1 file changed
+2
-1
+2
-1
@@ -8845,6 +8845,7 @@ static void mg_prepare_cgi_environment(struct mg_connection *nc,
|
|||||||
char *p;
|
char *p;
|
||||||
size_t i;
|
size_t i;
|
||||||
char buf[100];
|
char buf[100];
|
||||||
|
size_t path_info_len = path_info != NULL ? path_info->len : 0;
|
||||||
|
|
||||||
blk->len = blk->nvars = 0;
|
blk->len = blk->nvars = 0;
|
||||||
blk->nc = nc;
|
blk->nc = nc;
|
||||||
@@ -8876,7 +8877,7 @@ static void mg_prepare_cgi_environment(struct mg_connection *nc,
|
|||||||
mg_conn_addr_to_str(nc, buf, sizeof(buf), MG_SOCK_STRINGIFY_PORT);
|
mg_conn_addr_to_str(nc, buf, sizeof(buf), MG_SOCK_STRINGIFY_PORT);
|
||||||
mg_addenv(blk, "SERVER_PORT=%s", buf);
|
mg_addenv(blk, "SERVER_PORT=%s", buf);
|
||||||
|
|
||||||
s = hm->uri.p + hm->uri.len - path_info->len - 1;
|
s = hm->uri.p + hm->uri.len - path_info_len - 1;
|
||||||
if (*s == '/') {
|
if (*s == '/') {
|
||||||
const char *base_name = strrchr(prog, DIRSEP);
|
const char *base_name = strrchr(prog, DIRSEP);
|
||||||
mg_addenv(blk, "SCRIPT_NAME=%.*s/%s", (int) (s - hm->uri.p), hm->uri.p,
|
mg_addenv(blk, "SCRIPT_NAME=%.*s/%s", (int) (s - hm->uri.p), hm->uri.p,
|
||||||
|
|||||||
Reference in new issue
Block a user