@@ -1363,7 +1363,11 @@ TCN_IMPLEMENT_CALL(void, SSLContext, setSessionTicketKeys0)(TCN_STDARGS, jlong c
1363
1363
return ;
1364
1364
}
1365
1365
1366
- b = (* e )-> GetByteArrayElements (e , keys , NULL );
1366
+ if ((b = (* e )-> GetByteArrayElements (e , keys , NULL )) == NULL ) {
1367
+ tcn_ThrowException (e , "GetByteArrayElements() returned null" );
1368
+ return ;
1369
+ }
1370
+
1367
1371
for (i = 0 ; i < cnt ; ++ i ) {
1368
1372
key = b + (SSL_SESSION_TICKET_KEY_SIZE * i );
1369
1373
memcpy (ticket_keys [i ].key_name , key , 16 );
@@ -1495,7 +1499,7 @@ static jbyteArray get_certs(JNIEnv *e, SSL* ssl, STACK_OF(X509)* chain) {
1495
1499
length = i2d_X509 (cert , & buf );
1496
1500
#endif // OPENSSL_IS_BORINGSSL
1497
1501
1498
- if (length <= 0 || (bArray = (* e )-> NewByteArray (e , length )) == NULL ) {
1502
+ if (length <= 0 || (bArray = (* e )-> NewByteArray (e , length )) == NULL ) {
1499
1503
NETTY_JNI_UTIL_DELETE_LOCAL (e , array );
1500
1504
array = NULL ;
1501
1505
goto complete ;
@@ -2173,7 +2177,11 @@ static enum ssl_private_key_result_t tcn_private_key_sign_java(SSL *ssl, uint8_t
2173
2177
} else {
2174
2178
arrayLen = (* e )-> GetArrayLength (e , resultBytes );
2175
2179
if (max_out >= arrayLen ) {
2176
- b = (* e )-> GetByteArrayElements (e , resultBytes , NULL );
2180
+ if ((b = (* e )-> GetByteArrayElements (e , resultBytes , NULL )) == NULL ) {
2181
+ ret = ssl_private_key_failure ;
2182
+ goto complete ;
2183
+ }
2184
+
2177
2185
memcpy (out , b , arrayLen );
2178
2186
(* e )-> ReleaseByteArrayElements (e , resultBytes , b , JNI_ABORT );
2179
2187
* out_len = arrayLen ;
@@ -2238,7 +2246,11 @@ static enum ssl_private_key_result_t tcn_private_key_decrypt_java(SSL *ssl, uint
2238
2246
} else {
2239
2247
arrayLen = (* e )-> GetArrayLength (e , resultBytes );
2240
2248
if (max_out >= arrayLen ) {
2241
- b = (* e )-> GetByteArrayElements (e , resultBytes , NULL );
2249
+ if ((b = (* e )-> GetByteArrayElements (e , resultBytes , NULL )) == NULL ) {
2250
+ ret = ssl_private_key_failure ;
2251
+ goto complete ;
2252
+ }
2253
+
2242
2254
memcpy (out , b , arrayLen );
2243
2255
(* e )-> ReleaseByteArrayElements (e , resultBytes , b , JNI_ABORT );
2244
2256
* out_len = arrayLen ;
@@ -2300,7 +2312,9 @@ static enum ssl_private_key_result_t tcn_private_key_complete_java(SSL *ssl, uin
2300
2312
// belong to us.
2301
2313
return ssl_private_key_failure ;
2302
2314
}
2303
- b = (* e )-> GetByteArrayElements (e , resultBytes , NULL );
2315
+ if ((b = (* e )-> GetByteArrayElements (e , resultBytes , NULL )) == NULL ) {
2316
+ return ssl_private_key_failure ;
2317
+ }
2304
2318
memcpy (out , b , arrayLen );
2305
2319
(* e )-> ReleaseByteArrayElements (e , resultBytes , b , JNI_ABORT );
2306
2320
* out_len = arrayLen ;
0 commit comments