Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KostasTsiounis committed Dec 6, 2024
1 parent 619e5e4 commit 1cc6195
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions closed/src/java.base/share/native/libjncrypto/NativeCrypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@ find_crypto_library(jboolean traceEnabled, const char *chomepath)
* Since there is no indication of the version of a symlink,
* they have to be loaded first, so as to compare with other
* available options.
* Note: On macOS 11 or later, loading the general symlink causes
* a fatal warning and associated abort by default, so it is
* commented out and not used.
*
* The rest of the libraries are listed in descending order,
* which allows us to do two things:
Expand All @@ -653,8 +656,7 @@ find_crypto_library(jboolean traceEnabled, const char *chomepath)
"libcrypto.so.1.1", /* 1.1.x library name */
"libcrypto.so.1.0.0", /* 1.0.x library name */
#elif defined(__APPLE__) /* defined(_AIX) */
/* "libcrypto.dylib" In MacOS 11 or later, loading this symlink causes a
fatal warning and associated abort by default. */
/* "libcrypto.dylib" general symlink library name */
"libcrypto.3.dylib", /* 3.x library name */
"libcrypto.1.1.dylib", /* 1.1.x library name */
"libcrypto.1.0.0.dylib", /* 1.0.x library name */
Expand Down Expand Up @@ -791,7 +793,14 @@ Java_jdk_crypto_jniprovider_NativeCrypto_loadCrypto
jlong ossl_ver = 0;

if (NULL != jlibname) {
clibname = (*env)->GetStringUTFChars(env, jlibname, NULL);
const char *clibname = (*env)->GetStringUTFChars(env, jlibname, NULL);
if (NULL == clibname) {
if (traceEnabled) {
fprintf(stderr, "Failed to get jdk.native.openssl.lib value.\n");
fflush(stderr);
}
return -1;
}
if ('\0' == clibname[0]) {
if (traceEnabled) {
fprintf(stderr, "The jdk.native.openssl.lib property is not set.\n");
Expand All @@ -804,13 +813,22 @@ Java_jdk_crypto_jniprovider_NativeCrypto_loadCrypto
fprintf(stderr, "OpenSSL library specified in jdk.openssl.lib couldn't be loaded.\n");
fflush(stderr);
}
(*env)->ReleaseStringUTFChars(env, jlibname, clibname);
return -1;
}
}
(*env)->ReleaseStringUTFChars(env, jlibname, clibname);
}

if (NULL != jhomepath) {
chomepath = (*env)->GetStringUTFChars(env, jhomepath, NULL);
if (NULL == chomepath) {
if (traceEnabled) {
fprintf(stderr, "Failed to get java.home value.\n");
fflush(stderr);
}
return -1;
}
}

/* If the jdk.native.openssl.lib property was not set, attempt
Expand All @@ -820,8 +838,9 @@ Java_jdk_crypto_jniprovider_NativeCrypto_loadCrypto
crypto_library = find_crypto_library(traceEnabled, chomepath);
}

(*env)->ReleaseStringUTFChars(env, jlibname, clibname);
(*env)->ReleaseStringUTFChars(env, jhomepath, chomepath);
if (NULL != jhomepath) {
(*env)->ReleaseStringUTFChars(env, jhomepath, chomepath);
}

/* If an OpenSSL library was not loaded from any of the potential
* sources, fail loading native crypto.
Expand Down

0 comments on commit 1cc6195

Please sign in to comment.