mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

lutoff
20.28.2007 f7d666de2243ea8094d49f05f20111a6ffc71565
Fix for issue #1902 (dsconfig set-backend-prop  doesn't check max value)

If provided value exceeds lomg.MAX_VALUE, we now throw and exception
1 files modified
13 ■■■■ changed files
opends/src/server/org/opends/server/admin/SizeUnit.java 13 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/SizeUnit.java
@@ -365,9 +365,18 @@
   * @param amount
   *          The size as a quantity of this unit.
   * @return Returns the number of bytes that the size represents.
   *
   * @throws NumberFormatException
   *           If the provided size exceeded long.MAX_VALUE.
   */
  public long toBytes(double amount) {
    return (long) (sz * amount);
  public long toBytes(double amount) throws NumberFormatException {
    double value =  sz * amount;
    if (value > Long.MAX_VALUE)
    {
      throw new NumberFormatException
        ("number too big (exceeded long.MAX_VALUE");
    }
    return (long) (value);
  }