diff options
| author | 2023-12-18 09:35:22 +0100 | |
|---|---|---|
| committer | 2023-12-18 09:35:22 +0100 | |
| commit | 195c21ab2eb3217e9a018dd928e06c201f00a791 (patch) | |
| tree | e11212acaacc0a352e491c894d5a0121e2b3d164 /httpd.c | |
| parent | actor_request() accepts again an optional snac argument. (diff) | |
| download | snac2-195c21ab2eb3217e9a018dd928e06c201f00a791.tar.gz snac2-195c21ab2eb3217e9a018dd928e06c201f00a791.tar.xz snac2-195c21ab2eb3217e9a018dd928e06c201f00a791.zip | |
Avoid crashing on missing 'method' or 'path' headers in httpd_connection().
Diffstat (limited to 'httpd.c')
| -rw-r--r-- | httpd.c | 9 |
1 files changed, 7 insertions, 2 deletions
| @@ -245,8 +245,13 @@ void httpd_connection(FILE *f) | |||
| 245 | return; | 245 | return; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | method = xs_dict_get(req, "method"); | 248 | if (!(method = xs_dict_get(req, "method")) || !(p = xs_dict_get(req, "path"))) { |
| 249 | q_path = xs_dup(xs_dict_get(req, "path")); | 249 | /* missing needed headers; discard */ |
| 250 | fclose(f); | ||
| 251 | return; | ||
| 252 | } | ||
| 253 | |||
| 254 | q_path = xs_dup(p); | ||
| 250 | 255 | ||
| 251 | /* crop the q_path from leading / and the prefix */ | 256 | /* crop the q_path from leading / and the prefix */ |
| 252 | if (xs_endswith(q_path, "/")) | 257 | if (xs_endswith(q_path, "/")) |