summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Adenot <paul@paul.cx>2022-01-14 11:59:45 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-08 15:03:54 +0200
commitfaec3f2140ee5d068f17bd857f3e0a1e297d7fbd (patch)
tree89c63d1bed8239d68ea733103ca73b5c190a61b0
parentab5f44b61d054a29a34f6ff1bbdf0671395bbf61 (diff)
downloaduxp-faec3f2140ee5d068f17bd857f3e0a1e297d7fbd.tar.gz
[DOM media] Handle truncated ADTS and MP3 resources.
-rw-r--r--dom/media/ADTSDemuxer.cpp3
-rw-r--r--dom/media/mp3/MP3Demuxer.cpp3
2 files changed, 4 insertions, 2 deletions
diff --git a/dom/media/ADTSDemuxer.cpp b/dom/media/ADTSDemuxer.cpp
index 89148ce241..cc68a34947 100644
--- a/dom/media/ADTSDemuxer.cpp
+++ b/dom/media/ADTSDemuxer.cpp
@@ -819,8 +819,9 @@ ADTSTrackDemuxer::Read(uint8_t* aBuffer, int64_t aOffset, int32_t aSize)
const int64_t streamLen = StreamLength();
if (mInfo && streamLen > 0) {
+ int64_t max = streamLen > aOffset ? streamLen - aOffset : 0;
// Prevent blocking reads after successful initialization.
- aSize = std::min<int64_t>(aSize, streamLen - aOffset);
+ aSize = std::min<int64_t>(aSize, max);
}
uint32_t read = 0;
diff --git a/dom/media/mp3/MP3Demuxer.cpp b/dom/media/mp3/MP3Demuxer.cpp
index ccc515afb4..8fbe8da796 100644
--- a/dom/media/mp3/MP3Demuxer.cpp
+++ b/dom/media/mp3/MP3Demuxer.cpp
@@ -676,8 +676,9 @@ MP3TrackDemuxer::Read(uint8_t* aBuffer, int64_t aOffset, int32_t aSize) {
const int64_t streamLen = StreamLength();
if (mInfo && streamLen > 0) {
+ uint64_t max = streamLen > aOffset ? streamLen - aOffset : 0;
// Prevent blocking reads after successful initialization.
- aSize = std::min<int64_t>(aSize, streamLen - aOffset);
+ aSize = std::min<int64_t>(aSize, max);
}
uint32_t read = 0;