# HG changeset patch # User Paul Aurich # Date 1238881774 0 # Node ID 43cfca2eab647f141d39e28b7424570bbafe57c6 # Parent 680b54e417c1ce1cefe81764133010259f7e9d2f A better random number for the rid in the range [0, 2**52). diff -r 680b54e417c1 -r 43cfca2eab64 libpurple/protocols/jabber/bosh.c --- a/libpurple/protocols/jabber/bosh.c Sat Apr 04 20:59:15 2009 +0000 +++ b/libpurple/protocols/jabber/bosh.c Sat Apr 04 21:49:34 2009 +0000 @@ -176,8 +176,15 @@ g_free(passwd); conn->js = js; - /* FIXME: This doesn't seem very random */ - conn->rid = rand() % 100000 + 1728679472; + + /* + * Random 64-bit integer masked off by 2^52 - 1. + * + * This should produce a random integer in the range [0, 2^52). It's + * unlikely we'll send enough packets in one session to overflow the rid. + */ + conn->rid = ((guint64)g_random_int() << 32) | g_random_int(); + conn->rid &= 0xFFFFFFFFFFFFF; conn->pending = purple_circ_buffer_new(0 /* default grow size */);