зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1329480: [MSE] Do not reject partial boxes. r=gerald
Partial content less than 8 bytes long was incorrectly rejected. We now assume that content is valid unless it is explicitly incorrect (bad box type) MozReview-Commit-ID: 8L32mNVjzxh --HG-- extra : rebase_source : 980242aab96d5b96dc7e62ad289e8ecd7b228032
This commit is contained in:
Родитель
beac6277d5
Коммит
ff5bf730de
|
@ -20,6 +20,7 @@
|
|||
#endif
|
||||
#include "nsAutoPtr.h"
|
||||
#include "SourceBufferResource.h"
|
||||
#include <algorithm>
|
||||
|
||||
extern mozilla::LogModule* GetMediaSourceSamplesLog();
|
||||
|
||||
|
@ -348,6 +349,9 @@ public:
|
|||
// Each MP4 atom has a chunk size and chunk type. The root chunk in an MP4
|
||||
// file is the 'ftyp' atom followed by a file type. We just check for a
|
||||
// vaguely valid 'ftyp' atom.
|
||||
if (aData->Length() < 8) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
AtomParser parser(mType, aData);
|
||||
if (!parser.IsValid()) {
|
||||
return MediaResult(
|
||||
|
@ -359,6 +363,9 @@ public:
|
|||
|
||||
MediaResult IsMediaSegmentPresent(MediaByteBuffer* aData) override
|
||||
{
|
||||
if (aData->Length() < 8) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
AtomParser parser(mType, aData);
|
||||
if (!parser.IsValid()) {
|
||||
return MediaResult(
|
||||
|
@ -396,20 +403,15 @@ private:
|
|||
MSE_DEBUGV(AtomParser ,"Checking atom:'%c%c%c%c' @ %u",
|
||||
typec[0], typec[1], typec[2], typec[3],
|
||||
(uint32_t)reader.Offset() - 8);
|
||||
|
||||
for (const auto& boxType : validBoxes) {
|
||||
if (type == boxType) {
|
||||
mValid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!mValid) {
|
||||
// No point continuing.
|
||||
if (std::find(std::begin(validBoxes), std::end(validBoxes), type)
|
||||
== std::end(validBoxes)) {
|
||||
// No valid box found, no point continuing.
|
||||
mLastInvalidBox[0] = typec[0];
|
||||
mLastInvalidBox[1] = typec[1];
|
||||
mLastInvalidBox[2] = typec[2];
|
||||
mLastInvalidBox[3] = typec[3];
|
||||
mLastInvalidBox[4] = '\0';
|
||||
mValid = false;
|
||||
break;
|
||||
}
|
||||
if (mInitOffset.isNothing() &&
|
||||
|
@ -458,7 +460,7 @@ private:
|
|||
private:
|
||||
Maybe<size_t> mInitOffset;
|
||||
Maybe<size_t> mMediaOffset;
|
||||
bool mValid = false;
|
||||
bool mValid = true;
|
||||
char mLastInvalidBox[5];
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче