Skip to content
This repository was archived by the owner on May 17, 2023. It is now read-only.

Commit 510d19d

Browse files
filippenkosdmitryermilov
authored andcommitted
[jpegd] Check that number of scans is not exceeding maximum
1 parent c4fbaed commit 510d19d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

_studio/mfx_lib/decode/mjpeg/src/mfx_mjpeg_dec_decode.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,21 @@ mfxStatus VideoDECODEMJPEG::DecodeFrameCheck(mfxBitstream *bs, mfxFrameSurface1
857857
m_isHeaderFound = false;
858858
m_isHeaderParsed = false;
859859

860-
MFX_SAFE_CALL(decoder->AddPicture(pSrcData, numPic));
860+
try
861+
{
862+
MFX_SAFE_CALL(decoder->AddPicture(pSrcData, numPic));
863+
}
864+
catch(const UMC::eUMC_Status& sts)
865+
{
866+
if(sts == UMC::UMC_ERR_INVALID_STREAM)
867+
{
868+
continue;
869+
}
870+
else
871+
{
872+
return ConvertUMCStatusToMfx(sts);
873+
}
874+
}
861875
// make sure, that we collected BOTH fields
862876
} while (picToCollect > numPic);
863877

_studio/shared/umc/codec/jpeg_dec/src/mfx_mjpeg_task.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ mfxStatus CJpegTask::AddPicture(UMC::MediaDataEx *pSrcData,
249249
m_pics[m_numPic]->scanOffset[numScans] = pAuxData->offsets[i];
250250
m_pics[m_numPic]->scanSize[numScans] = chunkSize;
251251
numScans += 1;
252+
if (numScans >= maxNumScans)
253+
{
254+
throw UMC::UMC_ERR_INVALID_STREAM;
255+
}
252256
}
253257
else if ((JM_DRI == marker || JM_DQT == marker || JM_DHT == marker) && 0 != numScans)
254258
{

0 commit comments

Comments
 (0)