Relax check for unknown STUN attribute lengths

Bug: chromium:1155459
Change-Id: I51cb8162a989ba934e3292c86c3ecf749f26f601
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196500
Commit-Queue: Jonas Oreland <jonaso@google.com>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32773}
This commit is contained in:
Harald Alvestrand 2020-12-04 07:52:22 +00:00 committed by Commit Bot
parent 85e62e6d13
commit 837f13c84c

View file

@ -33,6 +33,7 @@ namespace {
const int k127Utf8CharactersLengthInBytes = 508;
const int kDefaultMaxAttributeLength = 508;
const int kMessageIntegrityAttributeLength = 20;
const int kTheoreticalMaximumAttributeLength = 65535;
uint32_t ReduceTransactionId(const std::string& transaction_id) {
RTC_DCHECK(transaction_id.length() == cricket::kStunTransactionIdLength ||
@ -77,10 +78,10 @@ bool LengthValid(int type, int length) {
// No length restriction in RFC; it's the content of an UDP datagram,
// which in theory can be up to 65.535 bytes.
// TODO(bugs.webrtc.org/12179): Write a test to find the real limit.
return length <= 65535;
return length <= kTheoreticalMaximumAttributeLength;
default:
// Return an arbitrary restriction for all other types.
return length <= kDefaultMaxAttributeLength;
return length <= kTheoreticalMaximumAttributeLength;
}
RTC_NOTREACHED();
return true;