img-parts icon indicating copy to clipboard operation
img-parts copied to clipboard

Incorrect segment length when there is entropy

Open mauricefisher64 opened this issue 1 year ago • 0 comments

The segment length for those containing entropy (SOS) is not correct. The length is being calculated as from the beginning of the segment to the end of the file as shown here from jpeg/image.rs in the function from_bytes

        let segment = JpegSegment::from_bytes(marker, &mut b)?;
        let has_entropy = segment.has_entropy();
        segments.push(segment);

        if has_entropy {
            break;
        }
    

So for the simple case this will also include the EOI in the size calculation. If there are other segments after the SOS they would also be included in this value.

mauricefisher64 avatar Jun 05 '23 15:06 mauricefisher64