upnpstun.c: fix generate_transaction_id()

This commit is contained in:
Thomas Bernard 2018-12-15 18:02:46 +01:00
parent f6fc66ee41
commit 6b4e9bd855
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
1 changed files with 3 additions and 11 deletions

View File

@ -45,18 +45,10 @@ static int delete_filter_rule(const char * ifname, unsigned short port, int prot
/* Generate random STUN Transaction Id */
static void generate_transaction_id(unsigned char transaction_id[12])
{
size_t i, n;
long value;
size_t i;
i = 0;
while (i < 12) {
value = random();
n = sizeof(value);
if (i + n > 12)
n = 12 - i;
memcpy(transaction_id + i, &value, n);
i += n;
}
for (i = 0; i < 12; i++)
transaction_id[i] = random() & 255;
}
/* Create and fill STUN Binding Request */