Fix UBsan error in TurnPortTest.TestChannelBindGetErrorResponse.

With the new version of UBsan, this test triggers:
../../p2p/base/turn_port.cc:1728:45: runtime error: left shift of negative value -1 because of:

message->AddAttribute(std::make_unique<StunUInt32Attribute>(
  STUN_ATTR_CHANNEL_NUMBER, channel_id_ << 16));

Bug: b/344601229
Change-Id: I8e730e805eb6bb70f141fc1c178d48a59575b612
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/353900
Auto-Submit: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42444}
This commit is contained in:
Mirko Bonadei 2024-06-07 09:03:24 +00:00 committed by WebRTC LUCI CQ
parent bd4dd67dde
commit d38b84ec27

View File

@ -1521,8 +1521,8 @@ TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) {
// TODO(deadbeef): SetEntryChannelId should not be a public method.
// Instead we should set an option on the fake TURN server to force it to
// send a channel bind errors.
ASSERT_TRUE(
turn_port_->SetEntryChannelId(udp_port_->Candidates()[0].address(), -1));
ASSERT_TRUE(turn_port_->SetEntryChannelId(
udp_port_->Candidates()[0].address(), /*channel_id=*/1));
std::string data = "ABC";
conn1->Send(data.data(), data.length(), options);