diff options
| author | 2024-01-11 21:33:41 +0100 | |
|---|---|---|
| committer | 2024-01-11 21:33:41 +0100 | |
| commit | 5532a3e8bdec92ada01bd844f796f0f95e9e312e (patch) | |
| tree | a5d3a1452683bf853ca49e5d076028b4b96c2765 | |
| parent | Avoid invalid actors in mastoapi_status(). (diff) | |
| download | penes-snac2-5532a3e8bdec92ada01bd844f796f0f95e9e312e.tar.gz penes-snac2-5532a3e8bdec92ada01bd844f796f0f95e9e312e.tar.xz penes-snac2-5532a3e8bdec92ada01bd844f796f0f95e9e312e.zip | |
More tries to fix crashes in mastoapi_account().
| -rw-r--r-- | mastoapi.c | 10 |
1 files changed, 8 insertions, 2 deletions
| @@ -494,7 +494,6 @@ xs_str *mastoapi_id(const xs_dict *msg) | |||
| 494 | xs_dict *mastoapi_account(const xs_dict *actor) | 494 | xs_dict *mastoapi_account(const xs_dict *actor) |
| 495 | /* converts an ActivityPub actor to a Mastodon account */ | 495 | /* converts an ActivityPub actor to a Mastodon account */ |
| 496 | { | 496 | { |
| 497 | xs_dict *acct = xs_dict_new(); | ||
| 498 | const char *prefu = xs_dict_get(actor, "preferredUsername"); | 497 | const char *prefu = xs_dict_get(actor, "preferredUsername"); |
| 499 | 498 | ||
| 500 | const char *display_name = xs_dict_get(actor, "name"); | 499 | const char *display_name = xs_dict_get(actor, "name"); |
| @@ -503,7 +502,12 @@ xs_dict *mastoapi_account(const xs_dict *actor) | |||
| 503 | 502 | ||
| 504 | const char *id = xs_dict_get(actor, "id"); | 503 | const char *id = xs_dict_get(actor, "id"); |
| 505 | const char *pub = xs_dict_get(actor, "published"); | 504 | const char *pub = xs_dict_get(actor, "published"); |
| 506 | xs *acct_md5 = xs_md5_hex(id, strlen(id)); | 505 | |
| 506 | if (xs_is_null(id)) | ||
| 507 | return NULL; | ||
| 508 | |||
| 509 | xs_dict *acct = xs_dict_new(); | ||
| 510 | xs *acct_md5 = xs_md5_hex(id, strlen(id)); | ||
| 507 | acct = xs_dict_append(acct, "id", acct_md5); | 511 | acct = xs_dict_append(acct, "id", acct_md5); |
| 508 | acct = xs_dict_append(acct, "username", prefu); | 512 | acct = xs_dict_append(acct, "username", prefu); |
| 509 | acct = xs_dict_append(acct, "display_name", display_name); | 513 | acct = xs_dict_append(acct, "display_name", display_name); |
| @@ -711,6 +715,8 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) | |||
| 711 | return NULL; | 715 | return NULL; |
| 712 | 716 | ||
| 713 | xs *acct = mastoapi_account(actor); | 717 | xs *acct = mastoapi_account(actor); |
| 718 | if (acct == NULL) | ||
| 719 | return NULL; | ||
| 714 | 720 | ||
| 715 | xs *idx = NULL; | 721 | xs *idx = NULL; |
| 716 | xs *ixc = NULL; | 722 | xs *ixc = NULL; |