On Fri, 20 Nov 2026 06:24:13 GMT, Timofei Fedotov <[email protected]> wrote:
>> convolveBI() and convolveRaster() entry points read kern[klen - 1] without >> requiring a nonempty kernel array. >> >> In JDK 25 and earlier, new Kernel(0, 0, new float[0]) is accepted by the >> constructor. If this reaches the native convolution code, kern[klen - 1] >> becomes kern[-1], an out-of-bounds read. >> >> JDK 26 added dimension validation to the Kernel constructor (JDK-8368729), >> but the native methods still read the dimensions and coefficient array >> directly from the object's fields. Inconsistent values can also be supplied >> through reflection. >> >> Both methods should reject invalid kernel dimensions and array lengths >> before accessing the coefficients. >> >> --------- >> - [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: > > Restore default switch branches Changes requested by prr (Reviewer). src/java.desktop/share/classes/sun/awt/image/ImagingLib.java line 80: > 78: double[] matrix, > 79: int interpType); > 80: public static native int convolveBINative(BufferedImage src, > BufferedImage dst, I think convolveBINative(..) can now be private, as it is used only from within this class. Same for the raster one. src/java.desktop/share/classes/sun/awt/image/ImagingLib.java line 106: > 104: > 105: if (width <= 0 || height <= 0 || > 106: (long) width * height != data.length) { You go to the trouble of checking in native whether data is null .. yet you've already de-referenced it here. src/java.desktop/share/classes/sun/awt/image/ImagingLib.java line 212: > 210: case CONVOLVE_OP: > 211: ConvolveOp cOp = (ConvolveOp) op; > 212: if (convolveRaster(src, dst, cOp.getKernel(), not sure why you made this cosmetic change src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c line 311: > 309: return 0; > 310: } > 311: so now there's no problem on the java side, why did you keep these ? My point was (and is) that we now know they are already validated by the caller. ------------- PR Review: https://git.openjdk.org/jdk/pull/33887#pullrequestreview-5999313633 PR Review Comment: https://git.openjdk.org/jdk/pull/33887#discussion_r4647650992 PR Review Comment: https://git.openjdk.org/jdk/pull/33887#discussion_r4647688249 PR Review Comment: https://git.openjdk.org/jdk/pull/33887#discussion_r4647650041 PR Review Comment: https://git.openjdk.org/jdk/pull/33887#discussion_r4647705254
