On Tue, 24 Nov 2026 08:50:21 GMT, Matthias Baesken <[email protected]> wrote:

>> We miss a couple of CFRelease calls in 
>> Java_apple_security_KeychainStore__1addItemToKeychain in case of early 
>> errors/returns.
>> Also a NULL  check after CFDataCreate is recommended.
>> See 
>> https://developer.apple.com/documentation/corefoundation/cfdatacreate(_:_:_:)
>>   about return value and ownership/Create rule.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Matthias Baesken has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Move rawData declaration

btw. I also noticed this code part in KeystoreImpl.m 

https://github.com/openjdk/jdk/blob/e289c72d86c1b8ed541b582d7014521d50e8e0a7/src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m#L136

    subjCerts = CFArrayCreateMutable(NULL, 1, &kCFTypeArrayCallBacks);
    CFArraySetValueAtIndex(subjCerts, 0, certRef);


But looking at the Apple manpage of 
https://developer.apple.com/documentation/corefoundation/cfarraycreatemutable(_:_:_:)
capacity
'The maximum number of values that can be contained by the new array. The array 
starts empty and can grow to this number of values (and it can have less).'

So we potentially write (set) with CFArraySetValueAtIndex to an empty array at 
first position.
This might cause trouble, should we change this ?

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

PR Comment: https://git.openjdk.org/jdk/pull/33999#issuecomment-7165911321

Reply via email to