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 authored and parrt committed Jun 25, 2022
1 parent 419ab11 commit 9d344f1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java
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 @@ -2184,11 +2187,13 @@ public Parser getParser() {

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

0 comments on commit 9d344f1

Please sign in to comment.