Skip to content

Commit ce670b6

Browse files
committedDec 4, 2023
8318951: Additional negative value check in JPEG decoding
Backport-of: 75ce02fe74e1232bfa8d72b4fdad82ed938ef957
1 parent 822c496 commit ce670b6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

‎src/java.desktop/share/native/libjavajpeg/imageioJPEG.c

+4
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,10 @@ imageio_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
11321132
return;
11331133
}
11341134
num_bytes += sb->remaining_skip;
1135+
// Check for overflow if remaining_skip value is too large
1136+
if (num_bytes < 0) {
1137+
return;
1138+
}
11351139
sb->remaining_skip = 0;
11361140

11371141
/* First the easy case where we are skipping <= the current contents. */

‎src/java.desktop/share/native/libjavajpeg/jpegdecoder.c

+4
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ sun_jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
406406
return;
407407
}
408408
num_bytes += src->remaining_skip;
409+
// Check for overflow if remaining_skip value is too large
410+
if (num_bytes < 0) {
411+
return;
412+
}
409413
src->remaining_skip = 0;
410414
ret = (int)src->pub.bytes_in_buffer; /* this conversion is safe, because capacity of the buffer is limited by jnit */
411415
if (ret >= num_bytes) {

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Dec 4, 2023

@openjdk-notifier[bot]
Please sign in to comment.