File tree Expand file tree Collapse file tree
src/test/com/wolfssl/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2237,6 +2237,11 @@ JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getAvailableCipherSuitesIana
22372237 }
22382238
22392239 numCiphers = sk_num (supportedCiphers );
2240+ if (numCiphers == 0 ) {
2241+ wolfSSL_free (ssl );
2242+ wolfSSL_CTX_free (ctx );
2243+ return NULL ;
2244+ }
22402245
22412246 for (i = 0 ; i < numCiphers ; i ++ ) {
22422247 cipher = (const WOLFSSL_CIPHER * )sk_value (supportedCiphers , i );
Original file line number Diff line number Diff line change @@ -214,6 +214,32 @@ public void testGetCiphersAvailableIana() {
214214 fail ("available ciphers array length was zero" );
215215 }
216216
217+ /* Test all protocol versions. For each, if a non-null list is returned
218+ * it must not be empty and must not contain empty strings. A null
219+ * return is acceptable for protocol versions not compiled into native
220+ * wolfSSL. */
221+ for (WolfSSL .TLS_VERSION ver : WolfSSL .TLS_VERSION .values ()) {
222+ if (ver == WolfSSL .TLS_VERSION .INVALID ) {
223+ continue ;
224+ }
225+ String [] verCiphers = WolfSSL .getCiphersAvailableIana (ver );
226+ if (verCiphers != null ) {
227+ if (verCiphers .length == 0 ) {
228+ System .out .println ("\t ... failed" );
229+ fail ("getCiphersAvailableIana(" + ver +
230+ ") returned empty array" );
231+ }
232+ for (int i = 0 ; i < verCiphers .length ; i ++) {
233+ if (verCiphers [i ] == null ||
234+ verCiphers [i ].isEmpty ()) {
235+ System .out .println ("\t ... failed" );
236+ fail ("getCiphersAvailableIana(" + ver +
237+ ") contains null/empty cipher at index " + i );
238+ }
239+ }
240+ }
241+ }
242+
217243 System .out .println ("\t ... passed" );
218244 }
219245
You can’t perform that action at this time.
0 commit comments