mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-15 17:27:02 +00:00
Bug 6873 - Finish moving from the non-threadsafe (and poor randomness) rand() to threadsafe ast_random()
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@17627 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2616,7 +2616,7 @@ static void start_rtp(struct mgcp_subchannel *sub)
|
||||
ast_rtp_set_data(p->rtp, p);
|
||||
#endif
|
||||
/* Make a call*ID */
|
||||
snprintf(sub->callid, sizeof(sub->callid), "%08x%s", rand(), sub->txident);
|
||||
snprintf(sub->callid, sizeof(sub->callid), "%08lx%s", ast_random(), sub->txident);
|
||||
/* Transmit the connection create */
|
||||
transmit_connect_with_sdp(sub, NULL);
|
||||
ast_mutex_unlock(&sub->lock);
|
||||
@@ -3785,7 +3785,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
strncpy(e->language, language, sizeof(e->language) - 1);
|
||||
strncpy(e->musicclass, musicclass, sizeof(e->musicclass) - 1);
|
||||
strncpy(e->mailbox, mailbox, sizeof(e->mailbox) - 1);
|
||||
snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08x", rand());
|
||||
snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", ast_random());
|
||||
e->msgstate = -1;
|
||||
e->amaflags = amaflags;
|
||||
e->capability = capability;
|
||||
@@ -3811,7 +3811,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
/* ASSUME we're onhook */
|
||||
e->hookstate = MGCP_ONHOOK;
|
||||
if (!ep_reload) {
|
||||
/*snprintf(txident, sizeof(txident), "%08x", rand());*/
|
||||
/*snprintf(txident, sizeof(txident), "%08lx", ast_random());*/
|
||||
for (i = 0; i < MAX_SUBS; i++) {
|
||||
sub = malloc(sizeof(struct mgcp_subchannel));
|
||||
if (sub) {
|
||||
@@ -3821,7 +3821,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
ast_mutex_init(&sub->cx_queue_lock);
|
||||
sub->parent = e;
|
||||
sub->id = i;
|
||||
snprintf(sub->txident, sizeof(sub->txident), "%08x", rand());
|
||||
snprintf(sub->txident, sizeof(sub->txident), "%08lx", ast_random());
|
||||
/*stnrcpy(sub->txident, txident, sizeof(sub->txident) - 1);*/
|
||||
sub->cxmode = MGCP_CX_INACTIVE;
|
||||
sub->nat = nat;
|
||||
@@ -3916,7 +3916,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
e->onhooktime = time(NULL);
|
||||
/* ASSUME we're onhook */
|
||||
e->hookstate = MGCP_ONHOOK;
|
||||
snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08x", rand());
|
||||
snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", ast_random());
|
||||
}
|
||||
|
||||
for (i = 0, sub = NULL; i < MAX_SUBS; i++) {
|
||||
@@ -3938,7 +3938,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
strncpy(sub->magic, MGCP_SUBCHANNEL_MAGIC, sizeof(sub->magic) - 1);
|
||||
sub->parent = e;
|
||||
sub->id = i;
|
||||
snprintf(sub->txident, sizeof(sub->txident), "%08x", rand());
|
||||
snprintf(sub->txident, sizeof(sub->txident), "%08lx", ast_random());
|
||||
sub->cxmode = MGCP_CX_INACTIVE;
|
||||
sub->next = e->sub;
|
||||
e->sub = sub;
|
||||
|
Reference in New Issue
Block a user