On Mon, 2 Nov 2026 07:44:31 GMT, Timofei Fedotov <[email protected]> wrote:
>> The legacy AWT JPEG decoder can write a synthetic two-byte JPEG EOI marker >> beyond the input buffer in sun_jpeg_fill_suspended_buffer(). >> >> The function retains unconsumed input bytes and reads into the remaining >> space. Its capacity check permits one remaining byte, but the EOF path >> writes two bytes. With a 1024-byte input buffer, offset 1023, and read() >> returning EOF, the second marker byte is written at index 1024. The path >> also requires available() to report more bytes than remaining_skip before >> the read; a stream whose availability estimate is inconsistent with the >> subsequent EOF can satisfy this condition. >> >> Truncated input must be rejected or handled without writing outside the >> input array. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Timofei Fedotov has updated the pull request incrementally with one > additional commit since the last revision: > > Use public AWT API in JPEG decoder regression test src/java.desktop/share/native/libjavajpeg/jpegdecoder.c line 354: > 352: buflen = (*env)->GetArrayLength(env, src->hInputBuffer); > 353: if (offset > buflen) { > 354: cinfo->err->error_exit((struct jpeg_common_struct *) cinfo); I don't think we call error_exit is these scenarios. We just return back to the caller(mostly libjpeg code). src/java.desktop/share/native/libjavajpeg/jpegdecoder.c line 373: > 371: WARNMS(cinfo, JWRN_JPEG_EOF); > 372: if (buflen < 2) { > 373: cinfo->err->error_exit((struct jpeg_common_struct *) cinfo); Same here. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/33313#discussion_r4491541165 PR Review Comment: https://git.openjdk.org/jdk/pull/33313#discussion_r4491542594
