@@ -665,6 +665,17 @@ find_crypto_library(jboolean traceEnabled, const char *chomepath)
665
665
#endif /* defined(_AIX) */
666
666
};
667
667
668
+ /** OpenSSL library names associated with bundled library. */
669
+ #if defined(_AIX )
670
+ static const char * const bundledLibName = "libcrypto-semeru.so" ;
671
+ #elif defined(__APPLE__ ) /* defined(_AIX) */
672
+ static const char * const bundledLibName = "libcrypto-semeru.dylib" ;
673
+ #elif defined(_WIN32 ) /* defined(__APPLE__) */
674
+ static const char * const bundledLibName = "crypto-semeru.dll" ;
675
+ #else /* defined(_WIN32) */
676
+ static const char * const bundledLibName = "libcrypto-semeru.so" ;
677
+ #endif /* defined(_AIX) */
678
+
668
679
const size_t numOfLibs = sizeof (libNames ) / sizeof (libNames [0 ]);
669
680
#if defined(_AIX )
670
681
const size_t num_of_generic = 4 ;
@@ -706,33 +717,31 @@ find_crypto_library(jboolean traceEnabled, const char *chomepath)
706
717
fprintf (stdout , "Attempting to load library bundled with JDK from: %s\n" , libPath );
707
718
}
708
719
709
- for (i = 0 ; i < numOfLibs ; i ++ ) {
710
- size_t file_len = strlen (libNames [i ]);
711
- /* Allocate memory for the new file name with the path. */
712
- char * libNameWithPath = (char * )malloc (path_len + file_len + 1 );
713
-
714
- if (NULL == libNameWithPath ) {
715
- if (traceEnabled ) {
716
- fprintf (stderr , "\tFailed to allocate memory for file name with path.\n" );
717
- }
718
- continue ;
719
- }
720
+ size_t file_len = strlen (bundledLibName );
721
+ /* Allocate memory for the new file name with the path. */
722
+ char * libNameWithPath = (char * )malloc (path_len + file_len + 1 );
720
723
721
- strcpy (libNameWithPath , libPath );
722
- strcat (libNameWithPath , libNames [i ]);
723
-
724
- /* Load OpenSSL Crypto library bundled with JDK. */
724
+ if (NULL == libNameWithPath ) {
725
725
if (traceEnabled ) {
726
- fprintf (stdout , "\tAttempting to load: %s \n" , libNames [ i ] );
726
+ fprintf (stderr , "\tFailed to allocate memory for file name with path. \n" );
727
727
}
728
- result = load_crypto_library (traceEnabled , libNameWithPath );
728
+ free (libPath );
729
+ return NULL ;
730
+ }
729
731
730
- free (libNameWithPath );
732
+ strcpy (libNameWithPath , libPath );
733
+ strcat (libNameWithPath , bundledLibName );
731
734
732
- if (NULL == result ) {
733
- continue ;
734
- }
735
+ /* Load OpenSSL Crypto library bundled with JDK. */
736
+ if (traceEnabled ) {
737
+ fprintf (stdout , "\tAttempting to load: %s\n" , bundledLibName );
738
+ }
739
+ result = load_crypto_library (traceEnabled , libNameWithPath );
735
740
741
+ free (libNameWithPath );
742
+ free (libPath );
743
+
744
+ if (NULL != result ) {
736
745
/* Identify and load the latest version from the potential libraries.
737
746
* This logic depends upon the order in which libnames are defined.
738
747
* Libraries are listed in descending order w.r.t version.
@@ -741,11 +750,9 @@ find_crypto_library(jboolean traceEnabled, const char *chomepath)
741
750
*/
742
751
tempVersion = get_crypto_library_version (traceEnabled , result , "\t\tLoaded OpenSSL version" );
743
752
if (tempVersion > 0 ) {
744
- free (libPath );
745
753
return result ;
746
754
}
747
755
}
748
- free (libPath );
749
756
}
750
757
751
758
/* The attempt to load from property and OpenSSL bundled with JDK failed.
0 commit comments