some more checks for int overflows

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1857609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2019-04-15 23:10:04 +00:00
parent c56ebe15af
commit cf5b72bc00
3 changed files with 4 additions and 3 deletions

View File

@ -154,7 +154,7 @@ public final class POIFSDocument implements POIFSViewable, Iterable<ByteBuffer>
}
}
return (int)length;
return Math.toIntExact(length);
}
/**

View File

@ -17,6 +17,7 @@
package org.apache.poi.poifs.property;
import org.apache.commons.math3.util.ArithmeticUtils;
import org.apache.poi.poifs.common.POIFSConstants;
/**
@ -55,7 +56,7 @@ public final class RootProperty extends DirectoryProperty {
{
final int BLOCK_SHIFT = 6;
final int _block_size = 1 << BLOCK_SHIFT;
super.setSize(size * _block_size);
super.setSize(ArithmeticUtils.mulAndCheck(size, _block_size));
}
/**

View File

@ -455,7 +455,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
Collections.sort(allValues);
}
int limit = (int) conf.getRank();
int limit = Math.toIntExact(conf.getRank());
if (conf.getPercent()) {
limit = allValues.size() * limit / 100;
}