diff options
author | Paul Adenot <paul@paul.cx> | 2022-01-14 11:59:45 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-04-03 01:07:42 +0200 |
commit | 230ddaa1d142da8de771f559f7a8c9220b29d854 (patch) | |
tree | 82ecec8754c9f64d0ff548d1750b2c61e44e6351 | |
parent | 275d2157fd97f543bff2fbd8e01ff09a01df0ebf (diff) | |
download | uxp-230ddaa1d142da8de771f559f7a8c9220b29d854.tar.gz |
[DOM media] Handle truncated ADTS and MP3 resources.
-rw-r--r-- | dom/media/ADTSDemuxer.cpp | 3 | ||||
-rw-r--r-- | dom/media/mp3/MP3Demuxer.cpp | 3 |
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; |