From b846c943b36cb6e2d74a49161678d78ad94ba62c Mon Sep 17 00:00:00 2001 From: default Date: Wed, 29 Nov 2023 08:58:31 +0100 Subject: [PATCH] Fixed crash in activitypub_request() when there is no payload. --- activitypub.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/activitypub.c b/activitypub.c index 4c8eaf5..e354a22 100644 --- a/activitypub.c +++ b/activitypub.c @@ -95,8 +95,14 @@ int activitypub_request(snac *snac, const char *url, xs_dict **data) status = 400; else if (xs_str_in(ctype, "application/activity+json") != -1 || - xs_str_in(ctype, "application/ld+json") != -1) - *data = xs_json_loads(payload); + xs_str_in(ctype, "application/ld+json") != -1) { + + /* if there is no payload, fail */ + if (xs_is_null(payload)) + status = 400; + else + *data = xs_json_loads(payload); + } else status = 500; }