diff options
author | Paul Adenot <paul@paul.cx> | 2022-01-14 11:59:45 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-04-08 15:03:54 +0200 |
commit | faec3f2140ee5d068f17bd857f3e0a1e297d7fbd (patch) | |
tree | 89c63d1bed8239d68ea733103ca73b5c190a61b0 | |
parent | ab5f44b61d054a29a34f6ff1bbdf0671395bbf61 (diff) | |
download | uxp-faec3f2140ee5d068f17bd857f3e0a1e297d7fbd.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; |