commit 195c21a
default
·
2023-12-18 08:35:22 +0000 UTC
parent af912db
Avoid crashing on missing 'method' or 'path' headers in httpd_connection().
1 files changed,
+7,
-2
M
httpd.c
M
httpd.c
+7,
-2
1@@ -245,8 +245,13 @@ void httpd_connection(FILE *f)
2 return;
3 }
4
5- method = xs_dict_get(req, "method");
6- q_path = xs_dup(xs_dict_get(req, "path"));
7+ if (!(method = xs_dict_get(req, "method")) || !(p = xs_dict_get(req, "path"))) {
8+ /* missing needed headers; discard */
9+ fclose(f);
10+ return;
11+ }
12+
13+ q_path = xs_dup(p);
14
15 /* crop the q_path from leading / and the prefix */
16 if (xs_endswith(q_path, "/"))