summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-04-28 08:28:17 +0200
committerdefault <nobody@localhost>2023-04-28 08:28:17 +0200
commitb620fe99fa99bb1658f43741b2d40ce88ff53963 (patch)
treefbbd8646043ebf4fb7123180e768d85383c0b656 /mastoapi.c
parente0cc5752b0e66a0ddc26233a053dc95a77d8953f (diff)
Ensure the new app client_id is unique.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 41f56af..5e20742 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1522,9 +1522,20 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
if (name && ruri) {
xs *app = xs_dict_new();
xs *id = xs_replace_i(tid(0), ".", "");
- xs *cid = random_str();
xs *csec = random_str();
xs *vkey = random_str();
+ xs *cid = NULL;
+
+ /* pick a non-existent random cid */
+ for (;;) {
+ cid = random_str();
+ xs *p_app = app_get(cid);
+
+ if (p_app == NULL)
+ break;
+
+ xs_free(cid);
+ }
app = xs_dict_append(app, "name", name);
app = xs_dict_append(app, "redirect_uri", ruri);