Skip to content
Permalink
Browse files

[FIXED JENKINS-25897] Add range check for H(X-Y) syntax

(cherry picked from commit 9a8329e)
  • Loading branch information...
daniel-beck authored and olivergondza committed Dec 23, 2014
1 parent dd2083a commit 6e67cb9e28707c19ded5c5c5c301ffe179ed5d64
Showing with 5 additions and 3 deletions.
  1. +1 −1 core/src/main/grammar/crontab.g
  2. +4 −2 core/src/main/java/hudson/scheduler/BaseParser.java
@@ -110,7 +110,7 @@ throws ANTLRException
}
| ("H" "(")=> "H" "(" s=token "-" e=token ")" ( "/" d=token )?
{
bits = doHash(s,e,d);
bits = doHash(s,e,d,field);
}
| "H" ( "/" d=token )?
{
@@ -96,10 +96,12 @@ protected long doHash(int step, int field) throws ANTLRException {
int u = UPPER_BOUNDS[field];
if (field==2) u = 28; // day of month can vary depending on month, so to make life simpler, just use [1,28] that's always safe
if (field==4) u = 6; // Both 0 and 7 of day of week are Sunday. For better distribution, limit upper bound to 6
return doHash(LOWER_BOUNDS[field], u, step);
return doHash(LOWER_BOUNDS[field], u, step, field);
}

protected long doHash(int s, int e, int step) throws ANTLRException {
protected long doHash(int s, int e, int step, int field) throws ANTLRException {
rangeCheck(s, field);
rangeCheck(e, field);
if (step > e - s + 1) {
error(Messages.BaseParser_OutOfRange(step, 1, e - s + 1));
throw new AssertionError();

0 comments on commit 6e67cb9

Please sign in to comment.
You can’t perform that action at this time.