commit b620fe9
default
·
2023-04-28 06:28:17 +0000 UTC
parent e0cc575
Ensure the new app client_id is unique.
1 files changed,
+12,
-1
+12,
-1
1@@ -1522,9 +1522,20 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
2 if (name && ruri) {
3 xs *app = xs_dict_new();
4 xs *id = xs_replace_i(tid(0), ".", "");
5- xs *cid = random_str();
6 xs *csec = random_str();
7 xs *vkey = random_str();
8+ xs *cid = NULL;
9+
10+ /* pick a non-existent random cid */
11+ for (;;) {
12+ cid = random_str();
13+ xs *p_app = app_get(cid);
14+
15+ if (p_app == NULL)
16+ break;
17+
18+ xs_free(cid);
19+ }
20
21 app = xs_dict_append(app, "name", name);
22 app = xs_dict_append(app, "redirect_uri", ruri);