@@ -662,6 +662,17 @@ find_crypto_library(jboolean traceEnabled, const char *chomepath)
662
662
#endif /* defined(_AIX) */
663
663
};
664
664
665
+ /** OpenSSL library names associated with bundled library. */
666
+ #if defined(_AIX )
667
+ static const char bundledLibName [] = "libcrypto-semeru.so" ;
668
+ #elif defined(__APPLE__ ) /* defined(_AIX) */
669
+ static const char bundledLibName [] = "libcrypto-semeru.dylib" ;
670
+ #elif defined(_WIN32 ) /* defined(__APPLE__) */
671
+ static const char bundledLibName [] = "crypto-semeru.dll" ;
672
+ #else /* defined(_WIN32) */
673
+ static const char bundledLibName [] = "libcrypto-semeru.so" ;
674
+ #endif /* defined(_AIX) */
675
+
665
676
const size_t numOfLibs = sizeof (libNames ) / sizeof (libNames [0 ]);
666
677
void * result = NULL ;
667
678
size_t i = 0 ;
@@ -675,7 +686,7 @@ find_crypto_library(jboolean traceEnabled, const char *chomepath)
675
686
static const char pathSuffix [] = "/lib/" ;
676
687
#endif /* defined(_WIN32) */
677
688
678
- size_t path_len = strlen (chomepath ) + sizeof (pathSuffix ) - 1 ;
689
+ size_t path_len = strlen (chomepath ) + sizeof (pathSuffix ) - 1 + sizeof ( bundledLibName ) - 1 ;
679
690
char * libPath = malloc (path_len + 1 );
680
691
681
692
if (NULL == libPath ) {
@@ -693,33 +704,17 @@ find_crypto_library(jboolean traceEnabled, const char *chomepath)
693
704
fprintf (stdout , "Attempting to load library bundled with JDK from: %s\n" , libPath );
694
705
}
695
706
696
- for (i = 0 ; i < numOfLibs ; i ++ ) {
697
- size_t file_len = strlen (libNames [i ]);
698
- /* Allocate memory for the new file name with the path. */
699
- char * libNameWithPath = (char * )malloc (path_len + file_len + 1 );
700
-
701
- if (NULL == libNameWithPath ) {
702
- if (traceEnabled ) {
703
- fprintf (stderr , "\tFailed to allocate memory for file name with path.\n" );
704
- }
705
- continue ;
706
- }
707
+ strcat (libPath , bundledLibName );
707
708
708
- strcpy (libNameWithPath , libPath );
709
- strcat (libNameWithPath , libNames [i ]);
710
-
711
- /* Load OpenSSL Crypto library bundled with JDK. */
712
- if (traceEnabled ) {
713
- fprintf (stdout , "\tAttempting to load: %s\n" , libNames [i ]);
714
- }
715
- result = load_crypto_library (traceEnabled , libNameWithPath );
716
-
717
- free (libNameWithPath );
709
+ /* Load OpenSSL Crypto library bundled with JDK. */
710
+ if (traceEnabled ) {
711
+ fprintf (stdout , "\tAttempting to load: %s\n" , bundledLibName );
712
+ }
713
+ result = load_crypto_library (traceEnabled , libPath );
718
714
719
- if (NULL == result ) {
720
- continue ;
721
- }
715
+ free (libPath );
722
716
717
+ if (NULL != result ) {
723
718
/* Identify and load the latest version from the potential libraries.
724
719
* This logic depends upon the order in which libnames are defined.
725
720
* Libraries are listed in descending order w.r.t version.
@@ -728,11 +723,9 @@ find_crypto_library(jboolean traceEnabled, const char *chomepath)
728
723
*/
729
724
tempVersion = get_crypto_library_version (traceEnabled , result , "\t\tLoaded OpenSSL version" );
730
725
if (tempVersion > 0 ) {
731
- free (libPath );
732
726
return result ;
733
727
}
734
728
}
735
- free (libPath );
736
729
}
737
730
738
731
/* The attempt to load from property and OpenSSL bundled with JDK failed.
0 commit comments