On Wed, 18 Nov 2026 05:18:16 GMT, Timofei Fedotov <[email protected]> wrote:

>  I'd prefer to keep the existing SAFE_TO_ALLOC semantics unchanged, since not 
> all callers require a signed integer bound.

Might be an option to have another macro for the cases where we want additional 
checks ? But maybe @prrace  or someone else from the 2d/client group can 
comment (@avu , @mrserb ?) .

> > Btw. what about this multiplication 
> > https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/native/libsplashscreen/splashscreen_impl.c#L149
> >  (stride * height, both int), should we guard/check or cast there too ?
> 
> Agreed. It’s also worth pointing out that screenStride can overflow before we 
> even get to malloc(), so casting the allocation size alone won’t fully solve 
> it. I’d rather track that separately, since it’s in the shared rendering code 
> and not really specific to the JPEG decoder.

No problem for me to track that separately.

> > Some more are here
> > https://github.com/openjdk/jdk/blob/8b5481d43fb8d4a922873a03070a0def806daa83/src/java.desktop/share/native/libsplashscreen/splashscreen_png.c#L115
> > 
> > https://github.com/openjdk/jdk/blob/8b5481d43fb8d4a922873a03070a0def806daa83/src/java.desktop/share/native/libsplashscreen/splashscreen_png.c#L154
> > 
> > (those at least have a SAFE_TO_ALLOC check, but considering your comments 
> > it might be not sufficient)
> 
> Thanks for pointing these out. The rowbytes * height multiplication uses 
> unsigned operands and is guarded by SAFE_TO_ALLOC, so it does not have the 
> same signed overflow issue.
> 
> However, the bitmap allocation uses signed integers and the preceding stride 
> calculation may also overflow. I will extend the fix to cover the 
> corresponding PNG allocation and cleanup paths soon.

Great, thanks!

-------------

PR Comment: https://git.openjdk.org/jdk/pull/33915#issuecomment-6973300260
PR Comment: https://git.openjdk.org/jdk/pull/33915#issuecomment-6973312783
PR Comment: https://git.openjdk.org/jdk/pull/33915#issuecomment-6973324773

Reply via email to