From cb55a025997776cec2ae7812221c67eb186f8463 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 22 Jan 2019 17:42:09 -0800 Subject: [PATCH] Fix parsing XOR-MAPPED-ADDRESS if the optional comprehension bit is set --- mist/stun.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mist/stun.cpp b/mist/stun.cpp index b8ffc3b..987b97e 100644 --- a/mist/stun.cpp +++ b/mist/stun.cpp @@ -179,7 +179,8 @@ bool getExternalAddressPortIP4(int proto, unsigned short localPort, PSOCKADDR_IN printf("STUN attribute out of bounds: %d\n", htons(attribute->length)); return false; } - else if (htons(attribute->type) != STUN_ATTRIBUTE_XOR_MAPPED_ADDRESS) { + // Mask off the comprehension bit + else if ((htons(attribute->type) & 0x7FFF) != STUN_ATTRIBUTE_XOR_MAPPED_ADDRESS) { // Continue searching if this wasn't our address bytesRead -= sizeof(*attribute) + htons(attribute->length); attribute = (PSTUN_ATTRIBUTE_HEADER)(((char*)attribute) + sizeof(*attribute) + htons(attribute->length));