diff options
| author | 2023-11-29 08:58:31 +0100 | |
|---|---|---|
| committer | 2023-11-29 08:58:31 +0100 | |
| commit | b846c943b36cb6e2d74a49161678d78ad94ba62c (patch) | |
| tree | ec6ddee9b0380c4aee4609437543aee5f25b3794 /activitypub.c | |
| parent | html_entry() returns an xs_html. (diff) | |
| download | snac2-b846c943b36cb6e2d74a49161678d78ad94ba62c.tar.gz snac2-b846c943b36cb6e2d74a49161678d78ad94ba62c.tar.xz snac2-b846c943b36cb6e2d74a49161678d78ad94ba62c.zip | |
Fixed crash in activitypub_request() when there is no payload.
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 10 |
1 files 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) | |||
| 95 | status = 400; | 95 | status = 400; |
| 96 | else | 96 | else |
| 97 | if (xs_str_in(ctype, "application/activity+json") != -1 || | 97 | if (xs_str_in(ctype, "application/activity+json") != -1 || |
| 98 | xs_str_in(ctype, "application/ld+json") != -1) | 98 | xs_str_in(ctype, "application/ld+json") != -1) { |
| 99 | *data = xs_json_loads(payload); | 99 | |
| 100 | /* if there is no payload, fail */ | ||
| 101 | if (xs_is_null(payload)) | ||
| 102 | status = 400; | ||
| 103 | else | ||
| 104 | *data = xs_json_loads(payload); | ||
| 105 | } | ||
| 100 | else | 106 | else |
| 101 | status = 500; | 107 | status = 500; |
| 102 | } | 108 | } |