summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Ptaszkiewicz2012-06-22 15:51:50 (EDT)
committer John Arthorne2012-06-22 15:51:50 (EDT)
commit2d6e94e8ac1415af460dcfcac5901a5e9edfe146 (patch)
treeb342bb2d6dd04d10dd0f291967aaf1d8b420e258
parentb8aff109797c8963222f0781daa84cea96e9b5ce (diff)
downloadeclipse.platform.runtime-2d6e94e8ac1415af460dcfcac5901a5e9edfe146.zip
eclipse.platform.runtime-2d6e94e8ac1415af460dcfcac5901a5e9edfe146.tar.gz
eclipse.platform.runtime-2d6e94e8ac1415af460dcfcac5901a5e9edfe146.tar.bz2
Bug 381724 - [jobs] ISchedulingRule security vulnerability
-rw-r--r--bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java2
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java26
2 files changed, 27 insertions, 1 deletions
diff --git a/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java b/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
index 1332932..102bf2e 100644
--- a/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
+++ b/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
@@ -329,7 +329,7 @@ class ThreadJob extends Job {
if (JobManager.DEBUG_BEGIN_END)
lastPush = (RuntimeException) new RuntimeException().fillInStackTrace();
//check for containment last because we don't want to fail again on endRule
- if (baseRule != null && rule != null && !baseRule.contains(rule))
+ if (baseRule != null && rule != null && !(baseRule.contains(rule) && baseRule.isConflicting(rule)))
illegalPush(rule, baseRule);
}
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java
index b8b3837..bacbcc9 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java
@@ -137,6 +137,32 @@ public class IJobManagerTest extends AbstractJobManagerTest {
// manager.startup();
}
+ public void testBeginInvalidNestedRules() {
+ final ISchedulingRule root = new PathRule("/");
+ final ISchedulingRule invalid = new ISchedulingRule() {
+ public boolean isConflicting(ISchedulingRule rule) {
+ return this == rule;
+ }
+
+ public boolean contains(ISchedulingRule rule) {
+ return this == rule || root.contains(rule);
+ }
+ };
+ try {
+ Job.getJobManager().beginRule(invalid, null);
+ try {
+ Job.getJobManager().beginRule(root, null);
+ fail("1.0");
+ } catch (IllegalArgumentException e) {
+ // expected
+ } finally {
+ Job.getJobManager().endRule(root);
+ }
+ } finally {
+ Job.getJobManager().endRule(invalid);
+ }
+ }
+
/**
* Tests running a job that begins a rule but never ends it
*/