Skip to content

Commit

Permalink
Issue 3720: Java 2 Security issue
Browse files Browse the repository at this point in the history
Signed-off-by: Will <dazeydev.3@gmail.com>
  • Loading branch information
dazey3 committed May 17, 2022
1 parent 7e8a8b5 commit 43feb82
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import org.antlr.v4.runtime.misc.IntervalSet;
import org.antlr.v4.runtime.misc.Pair;

import java.security.AccessController;
import java.security.PrivilegedAction;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
Expand Down Expand Up @@ -2183,12 +2186,11 @@ public Parser getParser() {
}

public static String getSafeEnv(String envName) {
try {
return System.getenv(envName);
}
catch(SecurityException e) {
// use the default value
}
return null;
return AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
public String run() {
return System.getenv(envName);
}
});
}
}

0 comments on commit 43feb82

Please sign in to comment.