Commit e2f01510 authored by Youness Alaoui's avatar Youness Alaoui

stupid WLM 2009 CRC32 typo workaround (ugly, I know...)

parent 455f2734
...@@ -146,6 +146,11 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg, ...@@ -146,6 +146,11 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
return STUN_VALIDATION_BAD_REQUEST; return STUN_VALIDATION_BAD_REQUEST;
} }
if (agent->compatibility == STUN_COMPATIBILITY_WLM2009)
wlm2009_stupid_crc32_typo = 1;
else
wlm2009_stupid_crc32_typo = 0;
/* Checks FINGERPRINT */ /* Checks FINGERPRINT */
crc32 = stun_fingerprint (msg->buffer, stun_message_length (msg)); crc32 = stun_fingerprint (msg->buffer, stun_message_length (msg));
fpr = ntohl (fpr); fpr = ntohl (fpr);
...@@ -575,6 +580,10 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg, ...@@ -575,6 +580,10 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
} }
if (agent->compatibility == STUN_COMPATIBILITY_WLM2009)
wlm2009_stupid_crc32_typo = 1;
else
wlm2009_stupid_crc32_typo = 0;
fpr = stun_fingerprint (msg->buffer, stun_message_length (msg)); fpr = stun_fingerprint (msg->buffer, stun_message_length (msg));
memcpy (ptr, &fpr, sizeof (fpr)); memcpy (ptr, &fpr, sizeof (fpr));
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
#include "stuncrc32.h" #include "stuncrc32.h"
int wlm2009_stupid_crc32_typo = 0;
static const uint32_t crc32_tab[] = { static const uint32_t crc32_tab[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
...@@ -147,8 +148,12 @@ uint32_t crc32 (const crc_data *data, size_t n) ...@@ -147,8 +148,12 @@ uint32_t crc32 (const crc_data *data, size_t n)
const uint8_t *p = data[i].buf; const uint8_t *p = data[i].buf;
size_t size = data[i].len; size_t size = data[i].len;
while (size--) while (size--) {
crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); uint32_t lkp = crc32_tab[(crc ^ *p++) & 0xFF];
if (lkp == 0x8bbeb8ea && wlm2009_stupid_crc32_typo)
lkp = 0x8bbe8ea;
crc = lkp ^ (crc >> 8);
}
} }
return crc ^ 0xffffffff; return crc ^ 0xffffffff;
......
...@@ -53,6 +53,7 @@ typedef struct { ...@@ -53,6 +53,7 @@ typedef struct {
} crc_data; } crc_data;
int wlm2009_stupid_crc32_typo;
uint32_t crc32 (const crc_data *data, size_t n); uint32_t crc32 (const crc_data *data, size_t n);
#endif /* _CRC32_H */ #endif /* _CRC32_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment