summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-06-01 08:47:50 +0200
committerdefault <nobody@localhost>2024-06-01 08:47:50 +0200
commit7a6b94a058dcef6f94eb98e404f56f2872ece3c5 (patch)
tree2983290b17767b0bc23548caa7b00969721d55c3 /mastoapi.c
parent9a1fc7980c1e7346b0609c513b9ff9b17cb4de89 (diff)
mastoapi: fix crashes on unset content-type.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 6c2c38c..a129ad0 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -243,6 +243,9 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
const char *i_ctype = xs_dict_get(req, "content-type");
xs *args = NULL;
+ if (i_ctype == NULL)
+ return 0;
+
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
if (!xs_is_null(payload))
args = xs_json_loads(payload);
@@ -2412,6 +2415,9 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
xs *args = NULL;
const char *i_ctype = xs_dict_get(req, "content-type");
+ if (i_ctype == NULL)
+ return 0;
+
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
if (!xs_is_null(payload))
args = xs_json_loads(payload);
@@ -3000,6 +3006,9 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path,
xs *args = NULL;
const char *i_ctype = xs_dict_get(req, "content-type");
+ if (i_ctype == NULL)
+ return 0;
+
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
if (!xs_is_null(payload))
args = xs_json_loads(payload);
@@ -3088,6 +3097,9 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path,
xs *args = NULL;
const char *i_ctype = xs_dict_get(req, "content-type");
+ if (i_ctype == NULL)
+ return 0;
+
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
if (!xs_is_null(payload))
args = xs_json_loads(payload);
@@ -3235,6 +3247,9 @@ int mastoapi_patch_handler(const xs_dict *req, const char *q_path,
xs *args = NULL;
const char *i_ctype = xs_dict_get(req, "content-type");
+ if (i_ctype == NULL)
+ return 0;
+
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
if (!xs_is_null(payload))
args = xs_json_loads(payload);