commit 7a6b94a
default
·
2024-06-01 06:47:50 +0000 UTC
parent 9a1fc79
mastoapi: fix crashes on unset content-type.
1 files changed,
+15,
-0
+15,
-0
1@@ -243,6 +243,9 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
2 const char *i_ctype = xs_dict_get(req, "content-type");
3 xs *args = NULL;
4
5+ if (i_ctype == NULL)
6+ return 0;
7+
8 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
9 if (!xs_is_null(payload))
10 args = xs_json_loads(payload);
11@@ -2412,6 +2415,9 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
12 xs *args = NULL;
13 const char *i_ctype = xs_dict_get(req, "content-type");
14
15+ if (i_ctype == NULL)
16+ return 0;
17+
18 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
19 if (!xs_is_null(payload))
20 args = xs_json_loads(payload);
21@@ -3000,6 +3006,9 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path,
22 xs *args = NULL;
23 const char *i_ctype = xs_dict_get(req, "content-type");
24
25+ if (i_ctype == NULL)
26+ return 0;
27+
28 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
29 if (!xs_is_null(payload))
30 args = xs_json_loads(payload);
31@@ -3088,6 +3097,9 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path,
32 xs *args = NULL;
33 const char *i_ctype = xs_dict_get(req, "content-type");
34
35+ if (i_ctype == NULL)
36+ return 0;
37+
38 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
39 if (!xs_is_null(payload))
40 args = xs_json_loads(payload);
41@@ -3235,6 +3247,9 @@ int mastoapi_patch_handler(const xs_dict *req, const char *q_path,
42 xs *args = NULL;
43 const char *i_ctype = xs_dict_get(req, "content-type");
44
45+ if (i_ctype == NULL)
46+ return 0;
47+
48 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
49 if (!xs_is_null(payload))
50 args = xs_json_loads(payload);