Commit 26b9379a authored by Michael Froman's avatar Michael Froman
Browse files

Bug 1828517 - Vendor libwebrtc from 778742963a

Upstream commit: https://webrtc.googlesource.com/src/+/778742963a089daf618fe1d5fbef58cf590cb6ed
    In remb parser discard bitrate larger than max int64_t

    Bug: b/265156399
    Change-Id: I5bdbd42a8da565972a3c2e976a32a563f3cce6af
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290888


    Reviewed-by: default avatarEmil Lundmark <lndmrk@webrtc.org>
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#39082}
parent 698b0a7a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -20862,3 +20862,6 @@ d22dc86211
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
43d4eee8ce
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
778742963a
+2 −0
Original line number Diff line number Diff line
@@ -13930,3 +13930,5 @@ libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-l
libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-04-21T03:45:46.779652.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-04-21T03:46:42.305967.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-04-21T03:47:37.767078.
+5 −5
Original line number Diff line number Diff line
@@ -67,15 +67,15 @@ bool Remb::Parse(const CommonHeader& packet) {
  }

  ParseCommonFeedback(payload);
  uint8_t exponenta = payload[13] >> 2;
  uint8_t exponent = payload[13] >> 2;
  uint64_t mantissa = (static_cast<uint32_t>(payload[13] & 0x03) << 16) |
                      ByteReader<uint16_t>::ReadBigEndian(&payload[14]);
  bitrate_bps_ = (mantissa << exponenta);
  bitrate_bps_ = (mantissa << exponent);
  bool shift_overflow =
      (static_cast<uint64_t>(bitrate_bps_) >> exponenta) != mantissa;
  if (shift_overflow) {
      (static_cast<uint64_t>(bitrate_bps_) >> exponent) != mantissa;
  if (bitrate_bps_ < 0 || shift_overflow) {
    RTC_LOG(LS_ERROR) << "Invalid remb bitrate value : " << mantissa << "*2^"
                      << static_cast<int>(exponenta);
                      << static_cast<int>(exponent);
    return false;
  }

+14 −1
Original line number Diff line number Diff line
@@ -101,13 +101,26 @@ TEST(RtcpPacketRembTest, ParseFailsWhenUniqueIdentifierIsNotRemb) {
TEST(RtcpPacketRembTest, ParseFailsWhenBitrateDoNotFitIn64bits) {
  uint8_t packet[kPacketLength];
  memcpy(packet, kPacket, kPacketLength);
  packet[17] |= 0xfc;  // Set exponenta component to maximum of 63.
  packet[17] |= 0xfc;  // Set exponent component to maximum of 63.
  packet[19] |= 0x02;  // Ensure mantissa is at least 2.

  Remb remb;
  EXPECT_FALSE(test::ParseSinglePacket(packet, &remb));
}

TEST(RtcpPacketRembTest, ParseFailsWhenBitrateDoNotFitIn63bits) {
  uint8_t packet[kPacketLength];
  memcpy(packet, kPacket, kPacketLength);
  packet[17] = 56 << 2;  // Set exponent component to 56.
  packet[18] = 0;        // Set mantissa to 200 > 128
  packet[19] = 200;

  // Result value 200 * 2^56 can't be represented with int64_t and thus should
  // be rejected.
  Remb remb;
  EXPECT_FALSE(test::ParseSinglePacket(packet, &remb));
}

TEST(RtcpPacketRembTest, ParseFailsWhenSsrcCountMismatchLength) {
  uint8_t packet[kPacketLength];
  memcpy(packet, kPacket, kPacketLength);