diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-10-21 09:56:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-21 09:56:15 +0200 |
commit | c4a52b13e856ecf6bade35d01aa6a75f4de3e3fc (patch) | |
tree | 2eefe61ded353c476a4d3a961929c777c1e68dbf /src/xmpp/jid.c | |
parent | 452a9f645e0f6232a03758942e85dcf0109a1ab9 (diff) | |
parent | 963ab841b42fdb1d80594b609a589a25b4034aa7 (diff) | |
download | profani-tty-c4a52b13e856ecf6bade35d01aa6a75f4de3e3fc.tar.gz |
Merge pull request #1209 from jubalh/feature/xep-0359
XEP-0359
Diffstat (limited to 'src/xmpp/jid.c')
-rw-r--r-- | src/xmpp/jid.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/xmpp/jid.c b/src/xmpp/jid.c index 49bf7b9c..25067050 100644 --- a/src/xmpp/jid.c +++ b/src/xmpp/jid.c @@ -198,18 +198,10 @@ jid_fulljid_or_barejid(Jid *jid) char* jid_random_resource(void) { - GRand *prng; - char rand[5]; - char alphabet[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + char *rand = get_random_string(4); - prng = g_rand_new(); + gchar *result = g_strdup_printf("profanity.%s", rand); + free(rand); - int i; - for (i = 0; i < 4; i++) { - rand[i] = alphabet[g_rand_int_range(prng, 0, sizeof(alphabet))]; - } - rand[4] = '\0'; - g_rand_free(prng); - - return g_strdup_printf("profanity.%s", rand); + return result; } |