--- pidgin-sipe-1.11.2/src/core/sip-sec-ntlm.c.bak 2011-05-04 22:24:46.666509267 +0300 +++ pidgin-sipe-1.11.2/src/core/sip-sec-ntlm.c 2011-05-04 22:24:48.647561792 +0300 @@ -454,7 +454,7 @@ NONCE(unsigned char *buffer, int num) { int i; for (i = 0; i < num; i++) { - buffer[i] = (rand() & 0xff); + buffer[i] = (get_random32() & 0xff); } } --- pidgin-sipe-1.11.2/src/core/sipe-chat.c.bak 2011-05-04 22:26:08.900689507 +0300 +++ pidgin-sipe-1.11.2/src/core/sipe-chat.c 2011-05-04 22:26:42.514580648 +0300 @@ -339,7 +339,7 @@ sipe_election_start(struct sipe_core_pri } else { session->is_voting_in_progress = TRUE; } - session->bid = rand(); + session->bid = get_random32(); SIPE_DEBUG_INFO("sipe_election_start: RM election has initiated. Our bid=%d", session->bid); --- pidgin-sipe-1.11.2/src/core/sipe.h.bak 2010-11-03 06:13:51.000000000 +0200 +++ pidgin-sipe-1.11.2/src/core/sipe.h 2011-05-04 22:33:01.741632485 +0300 @@ -30,6 +30,8 @@ * */ +#include + /* Forward declarations */ struct sipmsg; struct _PurpleAccount; @@ -157,6 +159,8 @@ struct sip_session; struct sip_dialog; struct transaction; +uint32_t get_random32(void); + void sipe_invite(struct sipe_core_private *sipe_private, struct sip_session *session, const gchar *who, const gchar *msg_body, const gchar *msg_content_type, --- pidgin-sipe-1.11.2/src/core/sip-transport.c.bak 2010-11-03 06:13:51.000000000 +0200 +++ pidgin-sipe-1.11.2/src/core/sip-transport.c 2011-05-04 22:34:30.926995958 +0300 @@ -120,8 +120,9 @@ static const char *transport_descriptor[ static char *genbranch() { return g_strdup_printf("z9hG4bK%04X%04X%04X%04X%04X", - rand() & 0xFFFF, rand() & 0xFFFF, rand() & 0xFFFF, - rand() & 0xFFFF, rand() & 0xFFFF); + get_random32() & 0xFFFF, get_random32() & 0xFFFF, + get_random32() & 0xFFFF, get_random32() & 0xFFFF, + get_random32() & 0xFFFF); } static void sipe_auth_free(struct sip_auth *auth) @@ -151,7 +152,7 @@ static void sipe_make_signature(struct s gchar *signature_input_str; msgbd.msg = msg; sipmsg_breakdown_parse(&msgbd, transport->registrar.realm, transport->registrar.target); - msgbd.rand = g_strdup_printf("%08x", g_random_int()); + msgbd.rand = g_strdup_printf("%08x", get_random32()); transport->registrar.ntlm_num++; msgbd.num = g_strdup_printf("%d", transport->registrar.ntlm_num); signature_input_str = sipmsg_breakdown_get_string(transport->registrar.version, &msgbd); --- pidgin-sipe-1.11.2/src/core/sipe-conf.c.bak 2010-11-03 06:13:51.000000000 +0200 +++ pidgin-sipe-1.11.2/src/core/sipe-conf.c 2011-05-04 22:27:33.427930365 +0300 @@ -188,14 +188,14 @@ static char * rand_guid() { return g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X", - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111); + get_random32() % 0xAAFF + 0x1111, + get_random32() % 0xAAFF + 0x1111, + get_random32() % 0xAAFF + 0x1111, + get_random32() % 0xAAFF + 0x1111, + get_random32() % 0xAAFF + 0x1111, + get_random32() % 0xAAFF + 0x1111, + get_random32() % 0xAAFF + 0x1111, + get_random32() % 0xAAFF + 0x1111); } /** @@ -597,7 +597,7 @@ sipe_conf_add(struct sipe_core_private * SIPE_SEND_CONF_ADD, sipe_private->focus_factory_uri, self, - rand(), + get_random32(), conference_id, expiry_time); g_free(self); --- pidgin-sipe-1.11.2/src/core/sipe-ft.c.bak 2011-05-04 22:27:58.126585103 +0300 +++ pidgin-sipe-1.11.2/src/core/sipe-ft.c 2011-05-04 22:28:01.381671392 +0300 @@ -175,7 +175,7 @@ static gboolean write_exact(struct sipe_ static void generate_key(guchar *buffer, gsize size) { gsize i = 0; - while (i < size) buffer[i++] = rand(); + while (i < size) buffer[i++] = get_random32(); } static gpointer sipe_cipher_context_init(const guchar *enc_key) @@ -233,7 +233,7 @@ struct sipe_file_transfer *sipe_core_ft_ g_new0(struct sipe_file_transfer_private, 1); ft_private->sipe_private = sipe_private; - ft_private->invitation_cookie = g_strdup_printf("%u", rand() % 1000000000); + ft_private->invitation_cookie = g_strdup_printf("%u", get_random32() % 1000000000); return(SIPE_FILE_TRANSFER_PUBLIC); } @@ -331,7 +331,7 @@ void sipe_core_ft_incoming_accept(struct struct sipe_file_transfer_private *ft_private = SIPE_FILE_TRANSFER_PRIVATE; gchar *body; - ft_private->auth_cookie = rand() % 1000000000; + ft_private->auth_cookie = get_random32() % 1000000000; body = g_strdup_printf("Invitation-Command: ACCEPT\r\n" "Invitation-Cookie: %s\r\n" --- pidgin-sipe-1.11.2/src/core/sipe.c.bak 2011-05-04 22:29:34.547140988 +0300 +++ pidgin-sipe-1.11.2/src/core/sipe.c 2011-05-04 22:31:54.547851686 +0300 @@ -1230,7 +1230,7 @@ sipe_buddy_subscribe_cb(char *buddy_name gchar *action_name = sipe_utils_presence_key(buddy_name); /* g_hash_table_size() can never return 0, otherwise this function wouldn't be called :-) */ guint time_range = (g_hash_table_size(sipe_private->buddies) * 1000) / 25; /* time interval for 25 requests per sec. In msec. */ - guint timeout = ((guint) rand()) / (RAND_MAX / time_range) + 1; /* random period within the range but never 0! */ + guint timeout = (get_random32() / time_range) + 1; /* random period within the range but never 0! */ sipe_schedule_mseconds(sipe_private, action_name, --- pidgin-sipe-1.11.2/src/core/sipe-incoming.c.bak 2011-05-04 22:28:15.736051906 +0300 +++ pidgin-sipe-1.11.2/src/core/sipe-incoming.c 2011-05-04 22:28:17.109088304 +0300 @@ -322,7 +322,7 @@ void process_incoming_invite(struct sipe session->with = NULL; was_multiparty = FALSE; session->is_multiparty = TRUE; - session->chat_id = rand(); + session->chat_id = get_random32(); } if (!session && is_multiparty) { --- pidgin-sipe-1.11.2/src/core/sipe-core.c.bak 2010-11-03 06:13:51.000000000 +0200 +++ pidgin-sipe-1.11.2/src/core/sipe-core.c 2011-05-04 22:23:42.949819855 +0300 @@ -48,7 +48,7 @@ void sipe_core_init(const char *locale_dir) { - srand(time(NULL)); + (void)get_random32(); sip_sec_init(); #ifdef ENABLE_NLS --- pidgin-sipe-1.11.2/src/core/sipe-session.c.bak 2011-05-04 22:28:29.240409883 +0300 +++ pidgin-sipe-1.11.2/src/core/sipe-session.c 2011-05-04 22:28:30.981456036 +0300 @@ -54,7 +54,7 @@ sipe_session_add_chat(struct sipe_core_p struct sip_session *session = g_new0(struct sip_session, 1); session->callid = gencallid(); session->is_multiparty = TRUE; - session->chat_id = rand(); + session->chat_id = get_random32(); session->unconfirmed_messages = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, (GDestroyNotify)sipe_free_queued_message); session->conf_unconfirmed_messages = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); --- pidgin-sipe-1.11.2/src/core/sipe-utils.c.bak 2011-05-04 22:28:49.208939206 +0300 +++ pidgin-sipe-1.11.2/src/core/sipe-utils.c 2011-05-04 22:29:09.966489432 +0300 @@ -52,7 +52,7 @@ #include "sipe.h" /* Generate 32 random bits */ -#define RANDOM32BITS (rand() & 0xFFFF) +#define RANDOM32BITS (get_random32() & 0xFFFF) gchar *gencallid(void) {