mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 03:24:38 +02:00
8073773: Presume path preparedness
Reviewed-by: darcy, dholmes, ahgross
This commit is contained in:
parent
5f7a2dfec6
commit
8c4275fcb7
3 changed files with 24 additions and 5 deletions
|
@ -611,7 +611,11 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative)
|
||||||
if (access(libjava, F_OK) == 0) {
|
if (access(libjava, F_OK) == 0) {
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
|
/* ensure storage for path + /jre + NULL */
|
||||||
|
if ((JLI_StrLen(path) + 4 + 1) > (size_t) pathsize) {
|
||||||
|
JLI_TraceLauncher("Insufficient space to store JRE path\n");
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
/* Does the app ship a private JRE in <apphome>/jre directory? */
|
/* Does the app ship a private JRE in <apphome>/jre directory? */
|
||||||
JLI_Snprintf(libjava, sizeof(libjava), "%s/jre/lib/" JAVA_DLL, path);
|
JLI_Snprintf(libjava, sizeof(libjava), "%s/jre/lib/" JAVA_DLL, path);
|
||||||
if (access(libjava, F_OK) == 0) {
|
if (access(libjava, F_OK) == 0) {
|
||||||
|
|
|
@ -340,6 +340,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
||||||
char* newpath = NULL; /* path on new LD_LIBRARY_PATH */
|
char* newpath = NULL; /* path on new LD_LIBRARY_PATH */
|
||||||
char* lastslash = NULL;
|
char* lastslash = NULL;
|
||||||
char** newenvp = NULL; /* current environment */
|
char** newenvp = NULL; /* current environment */
|
||||||
|
size_t new_runpath_size;
|
||||||
#ifdef __solaris__
|
#ifdef __solaris__
|
||||||
char* dmpath = NULL; /* data model specific LD_LIBRARY_PATH,
|
char* dmpath = NULL; /* data model specific LD_LIBRARY_PATH,
|
||||||
Solaris only */
|
Solaris only */
|
||||||
|
@ -516,13 +517,14 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
||||||
/* runpath contains current effective LD_LIBRARY_PATH setting */
|
/* runpath contains current effective LD_LIBRARY_PATH setting */
|
||||||
|
|
||||||
jvmpath = JLI_StringDup(jvmpath);
|
jvmpath = JLI_StringDup(jvmpath);
|
||||||
new_runpath = JLI_MemAlloc(((runpath != NULL) ? JLI_StrLen(runpath) : 0) +
|
new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) +
|
||||||
2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) +
|
2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) +
|
||||||
#ifdef AIX
|
#ifdef AIX
|
||||||
/* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */
|
/* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */
|
||||||
JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib//jli:") +
|
JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib//jli:") +
|
||||||
#endif
|
#endif
|
||||||
JLI_StrLen(jvmpath) + 52);
|
JLI_StrLen(jvmpath) + 52;
|
||||||
|
new_runpath = JLI_MemAlloc(new_runpath_size);
|
||||||
newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "=");
|
newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "=");
|
||||||
|
|
||||||
|
|
||||||
|
@ -577,6 +579,11 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
||||||
* loop of execv() because we test for the prefix, above.
|
* loop of execv() because we test for the prefix, above.
|
||||||
*/
|
*/
|
||||||
if (runpath != 0) {
|
if (runpath != 0) {
|
||||||
|
/* ensure storage for runpath + colon + NULL */
|
||||||
|
if ((JLI_StrLen(runpath) + 1 + 1) > new_runpath_size) {
|
||||||
|
JLI_ReportErrorMessageSys(JRE_ERROR11);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
JLI_StrCat(new_runpath, ":");
|
JLI_StrCat(new_runpath, ":");
|
||||||
JLI_StrCat(new_runpath, runpath);
|
JLI_StrCat(new_runpath, runpath);
|
||||||
}
|
}
|
||||||
|
@ -667,7 +674,11 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative)
|
||||||
JLI_TraceLauncher("JRE path is %s\n", path);
|
JLI_TraceLauncher("JRE path is %s\n", path);
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
|
/* ensure storage for path + /jre + NULL */
|
||||||
|
if ((JLI_StrLen(path) + 4 + 1) > (size_t) pathsize) {
|
||||||
|
JLI_TraceLauncher("Insufficient space to store JRE path\n");
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
/* Does the app ship a private JRE in <apphome>/jre directory? */
|
/* Does the app ship a private JRE in <apphome>/jre directory? */
|
||||||
JLI_Snprintf(libjava, sizeof(libjava), "%s/jre/lib/%s/" JAVA_DLL, path, arch);
|
JLI_Snprintf(libjava, sizeof(libjava), "%s/jre/lib/%s/" JAVA_DLL, path, arch);
|
||||||
if (access(libjava, F_OK) == 0) {
|
if (access(libjava, F_OK) == 0) {
|
||||||
|
|
|
@ -323,7 +323,11 @@ GetJREPath(char *path, jint pathsize)
|
||||||
JLI_TraceLauncher("JRE path is %s\n", path);
|
JLI_TraceLauncher("JRE path is %s\n", path);
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
|
/* ensure storage for path + \jre + NULL */
|
||||||
|
if ((JLI_StrLen(path) + 4 + 1) > (size_t) pathsize) {
|
||||||
|
JLI_TraceLauncher("Insufficient space to store JRE path\n");
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
/* Does this app ship a private JRE in <apphome>\jre directory? */
|
/* Does this app ship a private JRE in <apphome>\jre directory? */
|
||||||
JLI_Snprintf(javadll, sizeof (javadll), "%s\\jre\\bin\\" JAVA_DLL, path);
|
JLI_Snprintf(javadll, sizeof (javadll), "%s\\jre\\bin\\" JAVA_DLL, path);
|
||||||
if (stat(javadll, &s) == 0) {
|
if (stat(javadll, &s) == 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue