Skip to content

Commit

Permalink
Bugfix: Fixed security flaw with the Event Dispatch Thread, where rob…
Browse files Browse the repository at this point in the history
…ots could use the SwingUtilities.invokeLater() for running any code they should like
  • Loading branch information
flemming-n-larsen committed Dec 11, 2007
1 parent 1653bc7 commit 2f2867d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions robocode/robocode/security/RobocodeSecurityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,21 @@ public void checkPermission(Permission perm) {
return;
} catch (SecurityException e) {}

// Allow the Event Dispatch Thread
// Check if it was one of the tools for Robocode that was invoked by the Event Dispatch Thread
if (javax.swing.SwingUtilities.isEventDispatchThread()) {
return;
StackTraceElement[] stackTrace = new Throwable().getStackTrace();

for (StackTraceElement element : stackTrace) {
String classname = element.getClassName();
String method = element.getMethodName();

if (classname.equals("codesize.Codesize") && method.equals("processZipFile")) {
return;
}
if (classname.equals("ar.robocode.cachecleaner.CacheCleaner") && method.equals("clean")) {
return;
}
}
}

// For development purposes, allow read any file if override is set.
Expand Down

0 comments on commit 2f2867d

Please sign in to comment.