Skip to content

Commit

Permalink
Avoid divide-by-zero in webrtc::StreamStatisticianImpl::BitrateReceived
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=264718
<rdar://117912996>

Reviewed by Youenn Fablet.

Merge upstream 7dbf55437f109cb13d131d91ba645029686fa247 by
Harald Alvestrand <hta@webrtc.org>.

* Source/ThirdParty/libwebrtc/Source/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc:
* Source/ThirdParty/libwebrtc/Source/webrtc/test/fuzzers/utils/rtp_replayer.cc:

--

Ensure payload type frequency does not cause divide-by-zero

This CL does 2 things:
- Change the DCHECK for payload_type_frequency to a CHECK (so that
this error will be a crash not a divide-by-zero)
- Change the replay helper that was used by the fuzzer to set the
frequency of the packets to the video value (90K).

Bug: chromium:1466826
Change-Id: I39941f250b1782b36a3bcddfd347a016591466ec
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/312700
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40468}
Canonical link: https://commits.webkit.org/270656@main
  • Loading branch information
David Kilzer authored and ddkilzer committed Nov 13, 2023
1 parent 6f7a02c commit 01dea93
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ bool StreamStatisticianImpl::IsRetransmitOfOldPacket(
const RtpPacketReceived& packet,
int64_t now_ms) const {
uint32_t frequency_khz = packet.payload_type_frequency() / 1000;
RTC_DCHECK_GT(frequency_khz, 0);
RTC_CHECK_GT(frequency_khz, 0);

int64_t time_diff_ms = now_ms - last_receive_time_ms_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ void RtpReplayer::ReplayPackets(
RTC_LOG(LS_ERROR) << "Packet error, corrupt packets or incorrect setup?";
break;
}
// Set the clock rate - always 90K for video
received_packet.set_payload_type_frequency(kVideoPayloadTypeFrequency);

call->Receiver()->DeliverRtpPacket(
MediaType::VIDEO, std::move(received_packet),
Expand Down

0 comments on commit 01dea93

Please sign in to comment.