Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2023 from pjanouse/JENKINS-32852
[FIXED JENKINS-32852] Fixed possible ArrayIndexOutOfBoundsException
  • Loading branch information
olivergondza committed Feb 19, 2016
2 parents 90d7479 + 0f89ef4 commit 721d323
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions core/src/main/java/hudson/model/Fingerprint.java
Expand Up @@ -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;
Expand Down

0 comments on commit 721d323

Please sign in to comment.