diff options
| author | grunfink <grunfink@noreply.codeberg.org> | 2026-05-22 13:51:44 +0200 |
|---|---|---|
| committer | grunfink <grunfink@noreply.codeberg.org> | 2026-05-22 13:51:44 +0200 |
| commit | 400e2e2911575961d0d227852d1dfd00e0fe8bda (patch) | |
| tree | 3cc4fa961ff06a8d009b23646e8f77057a967d27 | |
| parent | 6c1c0ef0cd62e0d410484ad2d13f884e96eedafa (diff) | |
| parent | 4a5f9150d09474099bc1a8711a92ed1fe52203c0 (diff) | |
Merge pull request 'Fix error body leaks' (#614) from inz/snac2:fix/bad_request_leak into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/614
| -rw-r--r-- | httpd.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -600,17 +600,19 @@ void httpd_connection(FILE *f) status = HTTP_STATUS_NOT_FOUND; } - if (status == HTTP_STATUS_FORBIDDEN) - body = xs_str_new("<h1>403 Forbidden (" USER_AGENT ")</h1>"); + if (body == NULL) { + if (status == HTTP_STATUS_FORBIDDEN) + body = xs_str_new("<h1>403 Forbidden (" USER_AGENT ")</h1>"); - if (status == HTTP_STATUS_NOT_FOUND) - body = xs_str_new("<h1>404 Not Found (" USER_AGENT ")</h1>"); + if (status == HTTP_STATUS_NOT_FOUND) + body = xs_str_new("<h1>404 Not Found (" USER_AGENT ")</h1>"); - if (status == HTTP_STATUS_GONE) - body = xs_str_new("<h1>410 Gone (" USER_AGENT ")</h1>"); + if (status == HTTP_STATUS_GONE) + body = xs_str_new("<h1>410 Gone (" USER_AGENT ")</h1>"); - if (status == HTTP_STATUS_BAD_REQUEST && body != NULL) - body = xs_str_new("<h1>400 Bad Request (" USER_AGENT ")</h1>"); + if (status == HTTP_STATUS_BAD_REQUEST) + body = xs_str_new("<h1>400 Bad Request (" USER_AGENT ")</h1>"); + } if (status == HTTP_STATUS_SEE_OTHER) headers = xs_dict_append(headers, "location", body); |