Skip to content

Commit bffa3e9

Browse files
committed
Fixed issue with invalid RLE compressed DICOM images.
Fixed issue when processing an RLE compressed image where the RLE header contains an invalid stripe size. Thanks to Ding zhengzheng <[email protected]> for the report and the sample file (PoC).
1 parent ffe976f commit bffa3e9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

dcmdata/libsrc/dcrleccd.cc

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2002-2024, OFFIS e.V.
3+
* Copyright (C) 2002-2025, OFFIS e.V.
44
* All rights reserved. See COPYRIGHT file for details.
55
*
66
* This software and supporting documentation were developed by
@@ -362,6 +362,12 @@ OFCondition DcmRLECodecDecoder::decode(
362362
} /* while */
363363

364364
// last fragment for this RLE stripe
365+
if (inputBytes + byteOffset > fragmentLength)
366+
{
367+
DCMDATA_ERROR("stream size in RLE header is wrong");
368+
inputBytes = fragmentLength-byteOffset;
369+
}
370+
365371
result = rledecoder.decompress(rleData + byteOffset, OFstatic_cast(size_t, inputBytes));
366372

367373
// special handling for zero pad byte at the end of the RLE stream

0 commit comments

Comments
 (0)