commit be3e5c9
default
·
2023-12-18 12:24:07 +0000 UTC
parent 52f2712
Added some crash checks.
2 files changed,
+7,
-1
M
httpd.c
+6,
-0
1@@ -2323,6 +2323,12 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
2 return 400;
3 }
4
5+ if (xs_is_null(payload)) {
6+ *body = xs_str_new("no payload");
7+ *ctype = "text/plain";
8+ return 400;
9+ }
10+
11 if (xs_str_in(i_ctype, "application/activity+json") == -1 &&
12 xs_str_in(i_ctype, "application/ld+json") == -1)
13 return 0;
M
httpd.c
+1,
-1
1@@ -382,7 +382,7 @@ void httpd_connection(FILE *f)
2 srv_archive("RECV", NULL, req, payload, p_size, status, headers, body, b_size);
3
4 /* JSON validation check */
5- if (strcmp(ctype, "application/json") == 0) {
6+ if (!xs_is_null(body) && strcmp(ctype, "application/json") == 0) {
7 xs *j = xs_json_loads(body);
8
9 if (j == NULL) {