Skip to content
Permalink
Browse files
[JENKINS-32852] Fixed possible ArrayIndexOutOfBoundsException in Rang…
…eSet.fromString()

Fixed possible ArrayIndexOutOfBoundsException in
hudson.model.Fingerprint.RangeSet.fromString(...)
  • Loading branch information
pjanouse committed Feb 15, 2016
1 parent 51f215c commit 0f89ef4162f5c9e0da687f51b1eae61aa512c4f9
Showing with 11 additions and 3 deletions.
  1. +11 −3 core/src/main/java/hudson/model/Fingerprint.java
@@ -694,16 +694,24 @@ public static RangeSet fromString(String list, boolean skipError) {
try {
if(s.contains("-")) {
String[] tokens = Util.tokenize(s,"-");
rs.ranges.add(new Range(Integer.parseInt(tokens[0]),Integer.parseInt(tokens[1])+1));
if (tokens.length == 2) {
rs.ranges.add(new Range(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]) + 1));
} else {
if (!skipError) {
throw new IllegalArgumentException(
String.format("Unable to parse %s, expected string with a range M-N", list));
}
// ignore malformed text like "1-10-50"
}
} else {
int n = Integer.parseInt(s);
rs.ranges.add(new Range(n,n+1));
}
} catch (NumberFormatException e) {
if (!skipError)
throw new IllegalArgumentException("Unable to parse "+list);
throw new IllegalArgumentException(
String.format("Unable to parse %s, expected number", list));
// ignore malformed text

}
}
return rs;

0 comments on commit 0f89ef4

Please sign in to comment.