Fix parsing XOR-MAPPED-ADDRESS if the optional comprehension bit is set

This commit is contained in:
Cameron Gutman
2019-01-22 17:42:09 -08:00
parent dc820bdbf6
commit cb55a02599
+2 -1
View File
@@ -179,7 +179,8 @@ bool getExternalAddressPortIP4(int proto, unsigned short localPort, PSOCKADDR_IN
printf("STUN attribute out of bounds: %d\n", htons(attribute->length)); printf("STUN attribute out of bounds: %d\n", htons(attribute->length));
return false; 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 // Continue searching if this wasn't our address
bytesRead -= sizeof(*attribute) + htons(attribute->length); bytesRead -= sizeof(*attribute) + htons(attribute->length);
attribute = (PSTUN_ATTRIBUTE_HEADER)(((char*)attribute) + sizeof(*attribute) + htons(attribute->length)); attribute = (PSTUN_ATTRIBUTE_HEADER)(((char*)attribute) + sizeof(*attribute) + htons(attribute->length));