commit 5532a3e
default
·
2024-01-11 20:33:41 +0000 UTC
parent adf5623
More tries to fix crashes in mastoapi_account().
1 files changed,
+8,
-2
+8,
-2
1@@ -494,7 +494,6 @@ xs_str *mastoapi_id(const xs_dict *msg)
2 xs_dict *mastoapi_account(const xs_dict *actor)
3 /* converts an ActivityPub actor to a Mastodon account */
4 {
5- xs_dict *acct = xs_dict_new();
6 const char *prefu = xs_dict_get(actor, "preferredUsername");
7
8 const char *display_name = xs_dict_get(actor, "name");
9@@ -503,7 +502,12 @@ xs_dict *mastoapi_account(const xs_dict *actor)
10
11 const char *id = xs_dict_get(actor, "id");
12 const char *pub = xs_dict_get(actor, "published");
13- xs *acct_md5 = xs_md5_hex(id, strlen(id));
14+
15+ if (xs_is_null(id))
16+ return NULL;
17+
18+ xs_dict *acct = xs_dict_new();
19+ xs *acct_md5 = xs_md5_hex(id, strlen(id));
20 acct = xs_dict_append(acct, "id", acct_md5);
21 acct = xs_dict_append(acct, "username", prefu);
22 acct = xs_dict_append(acct, "display_name", display_name);
23@@ -711,6 +715,8 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
24 return NULL;
25
26 xs *acct = mastoapi_account(actor);
27+ if (acct == NULL)
28+ return NULL;
29
30 xs *idx = NULL;
31 xs *ixc = NULL;