Chromium Code Reviews| Index: webrtc/p2p/base/stun.cc |
| diff --git a/webrtc/p2p/base/stun.cc b/webrtc/p2p/base/stun.cc |
| index 180597ee77c11a46e52d379cf1c2fe5d7450291f..60b9c6e5e49957c0ef4cc84822751ccefba479eb 100644 |
| --- a/webrtc/p2p/base/stun.cc |
| +++ b/webrtc/p2p/base/stun.cc |
| @@ -145,7 +145,7 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, |
| // Finding Message Integrity attribute in stun message. |
| size_t current_pos = kStunHeaderSize; |
| bool has_message_integrity_attr = false; |
| - while (current_pos < size) { |
| + while (current_pos + 4 < size) { |
|
Sergey Ulanov
2016/06/18 00:25:54
I think this should be <=, in case there is an att
katrielc
2016/06/20 11:23:57
Don't think we support any length-0 extensions at
|
| uint16_t attr_type, attr_length; |
| // Getting attribute type and length. |
| attr_type = rtc::GetBE16(&data[current_pos]); |
| @@ -154,7 +154,8 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, |
| // If M-I, sanity check it, and break out. |
| if (attr_type == STUN_ATTR_MESSAGE_INTEGRITY) { |
| if (attr_length != kStunMessageIntegritySize || |
| - current_pos + attr_length > size) { |
| + current_pos + sizeof(attr_type) + sizeof(attr_length) + attr_length > |
| + size) { |
| return false; |
| } |
| has_message_integrity_attr = true; |