Hi all,

Function handleMessage in file 
src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c declare 'struct controlData 
cdata[1]' but do not initiali the struct variable. After the declation, the 
cdata will write the related data through funciton call 'getControlData(msg, 
cdata)', and the data will be readed through '(*env)->NewObject'. During 
'getControlData(msg, cdata)' call the cdate maybe unchange and then return.

In C/C++, read the variable which has not been uninitializaed is undefined 
behavior. I think it's better to initial the cdata, this will avoid the 
compiler use too aggressive optimilization.

Before this PR, com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java crash 'C  
[libsctp.so+0x3b3e]  handleMessage+0x4e' with clang23/llvm23 release build . 
After this PR test run passed.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - 8381851: handleMessage use uninitialized struct

Changes: https://git.openjdk.org/jdk/pull/30664/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=30664&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8381851
  Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/30664.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/30664/head:pull/30664

PR: https://git.openjdk.org/jdk/pull/30664

Reply via email to