Skip to content

Commit

Permalink
b2b_entities: add more entropy to from_tag generation
Browse files Browse the repository at this point in the history
The initial from-tag generation cosisted of an md5 hash over the From
URI. Thus, if you would have generating client requests to the same
entity (such as a media server), you would always get the same from-tag
for all those requests.
The current patch adds more entropy when generating the from_tag, such
as the current timestamp (expressed in milliseconds) along with the
process pid.

(cherry picked from commit b003891)
  • Loading branch information
razvancrainea committed Dec 5, 2022
1 parent bd00ee2 commit 3861f45
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion modules/b2b_entities/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,20 @@ static char from_tag[FROM_TAG_LEN + 1];
static void generate_tag(str* tag, str* src, str* callid)
{
int len;
str srcs[4];
struct timeval tv;

MD5StringArray(from_tag, src, 1);
gettimeofday(&tv, NULL);

srcs[0] = *src;
srcs[1].s = (char *)&tv.tv_sec;
srcs[1].len = sizeof(tv.tv_sec);
srcs[2].s = (char *)&tv.tv_usec;
srcs[2].len = sizeof(tv.tv_usec);
srcs[3].s = (char *)&process_no;
srcs[3].len = sizeof(process_no);

MD5StringArray(from_tag, srcs, 4);
len = MD5_LEN;

/* calculate from tag from callid */
Expand Down

0 comments on commit 3861f45

Please sign in to comment.