mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8217216: Launcher does not defend itself against LD_LIBRARY_PATH_64 (Solaris)
Reviewed-by: rriggs
This commit is contained in:
parent
c2ec1085e1
commit
b481f5bd24
2 changed files with 42 additions and 3 deletions
|
@ -303,6 +303,9 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
||||||
|
|
||||||
#ifdef SETENV_REQUIRED
|
#ifdef SETENV_REQUIRED
|
||||||
jboolean mustsetenv = JNI_FALSE;
|
jboolean mustsetenv = JNI_FALSE;
|
||||||
|
#ifdef __solaris__
|
||||||
|
char *llp64 = NULL; /* existing LD_LIBRARY_PATH_64 setting */
|
||||||
|
#endif // __solaris__
|
||||||
char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */
|
char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */
|
||||||
char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
|
char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
|
||||||
char* newpath = NULL; /* path on new LD_LIBRARY_PATH */
|
char* newpath = NULL; /* path on new LD_LIBRARY_PATH */
|
||||||
|
@ -367,7 +370,12 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
||||||
* any.
|
* any.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __solaris__
|
||||||
|
llp64 = getenv("LD_LIBRARY_PATH_64");
|
||||||
|
runpath = (llp64 == NULL) ? getenv(LD_LIBRARY_PATH) : llp64;
|
||||||
|
#else
|
||||||
runpath = getenv(LD_LIBRARY_PATH);
|
runpath = getenv(LD_LIBRARY_PATH);
|
||||||
|
#endif /* __solaris__ */
|
||||||
|
|
||||||
/* runpath contains current effective LD_LIBRARY_PATH setting */
|
/* runpath contains current effective LD_LIBRARY_PATH setting */
|
||||||
{ /* New scope to declare local variable */
|
{ /* New scope to declare local variable */
|
||||||
|
@ -440,6 +448,14 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
||||||
* once at startup, so we have to re-exec the current executable
|
* once at startup, so we have to re-exec the current executable
|
||||||
* to get the changed environment variable to have an effect.
|
* to get the changed environment variable to have an effect.
|
||||||
*/
|
*/
|
||||||
|
#ifdef __solaris__
|
||||||
|
/*
|
||||||
|
* new LD_LIBRARY_PATH took over for LD_LIBRARY_PATH_64
|
||||||
|
*/
|
||||||
|
if (llp64 != NULL) {
|
||||||
|
UnsetEnv("LD_LIBRARY_PATH_64");
|
||||||
|
}
|
||||||
|
#endif // __solaris__
|
||||||
|
|
||||||
newenvp = environ;
|
newenvp = environ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 7029048 8217340
|
* @bug 7029048 8217340 8217216
|
||||||
* @summary Ensure that the launcher defends against user settings of the
|
* @summary Ensure that the launcher defends against user settings of the
|
||||||
* LD_LIBRARY_PATH environment variable on Unixes
|
* LD_LIBRARY_PATH environment variable on Unixes
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
|
@ -89,6 +89,29 @@ public class Test7029048 extends TestHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void analyze(TestResult tr, int nLLPComponents, String caseID) {
|
static void analyze(TestResult tr, int nLLPComponents, String caseID) {
|
||||||
|
if (isSolaris) {
|
||||||
|
String envValue = getValue("LD_LIBRARY_PATH_64", tr.testOutput);
|
||||||
|
/*
|
||||||
|
* the envValue can never be null, since the test code should always
|
||||||
|
* print a "null" string.
|
||||||
|
*/
|
||||||
|
if (envValue == null) {
|
||||||
|
throw new RuntimeException("NPE, likely a program crash ??");
|
||||||
|
}
|
||||||
|
boolean noLLP64 = envValue.equals("null");
|
||||||
|
if (nLLPComponents == 0 && noLLP64) {
|
||||||
|
System.out.println("FAIL: test7029048, " + caseID);
|
||||||
|
System.out.println(" Missing LD_LIBRARY_PATH_64");
|
||||||
|
errors++;
|
||||||
|
return;
|
||||||
|
} else if (nLLPComponents > 3 && !noLLP64) {
|
||||||
|
System.out.println("FAIL: test7029048, " + caseID);
|
||||||
|
System.out.println(" Unexpected LD_LIBRARY_PATH_64: " + envValue);
|
||||||
|
errors++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String envValue = getValue(LD_LIBRARY_PATH, tr.testOutput);
|
String envValue = getValue(LD_LIBRARY_PATH, tr.testOutput);
|
||||||
/*
|
/*
|
||||||
* the envValue can never be null, since the test code should always
|
* the envValue can never be null, since the test code should always
|
||||||
|
@ -202,8 +225,8 @@ public class Test7029048 extends TestHelper {
|
||||||
env.clear();
|
env.clear();
|
||||||
env.put(LD_LIBRARY_PATH_64, dstServerDir.getAbsolutePath());
|
env.put(LD_LIBRARY_PATH_64, dstServerDir.getAbsolutePath());
|
||||||
run(env,
|
run(env,
|
||||||
v.value, // Do not add one, since we didn't set
|
// LD_LIBRARY_PATH_64 is copied into LD_LIBRARY_PATH for LIBJVM case
|
||||||
// LD_LIBRARY_PATH here
|
v.value == 0 ? 0 : v.value + 1,
|
||||||
"Case 3: " + desc);
|
"Case 3: " + desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue