Skip to content

Commit bd03fd4

Browse files
committed
LJpegDecompressor: avoid overflow when calculating LJpeg frame per-line pixel count
1 parent 79dd733 commit bd03fd4

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/librawspeed/decompressors/LJpegDecompressor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ LJpegDecompressor::LJpegDecompressor(const RawImage& img,
9292
if ((unsigned)frame.cps < mRaw->getCpp())
9393
ThrowRDE("Unexpected number of components");
9494

95+
if ((int64_t)frame.cps * frame.dim.x > std::numeric_limits<int>::max())
96+
ThrowRDE("LJpeg frame is too big");
97+
9598
invariant(mRaw->dim.x > imgFrame.pos.x);
9699
if (((int)mRaw->getCpp() * (mRaw->dim.x - imgFrame.pos.x)) < frame.cps)
97100
ThrowRDE("Got less pixels than the components per sample");

0 commit comments

Comments
 (0)