Skip to content

Commit

Permalink
broken per infinite gas CVE
Browse files Browse the repository at this point in the history
Signed-off-by: Danno Ferrin <[email protected]>
  • Loading branch information
shemnon committed Sep 29, 2023
1 parent 513e0f6 commit a51ffe2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.internal.Words;

/** The Tangerine whistle gas calculator. */
public class TangerineWhistleGasCalculator extends HomesteadGasCalculator {
Expand Down Expand Up @@ -84,7 +83,7 @@ public long callOperationGasCost(
}

private static long gasCap(final long remaining, final long stipend) {
return Words.unsignedMin(allButOneSixtyFourth(remaining), stipend);
return Math.min(allButOneSixtyFourth(remaining), stipend);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*/
package org.hyperledger.besu.evm.operation;

import static org.hyperledger.besu.evm.internal.Words.clampedToLong;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.Code;
Expand Down Expand Up @@ -65,7 +63,11 @@ public abstract class AbstractCallOperation extends AbstractOperation {
* @return the additional gas to provide the call operation
*/
protected long gas(final MessageFrame frame) {
return clampedToLong(frame.getStackItem(0));
try {
return frame.getStackItem(0).trimLeadingZeros().toLong();
} catch (final ArithmeticException | IllegalArgumentException ae) {
return Long.MAX_VALUE;
}
}

/**
Expand Down

0 comments on commit a51ffe2

Please sign in to comment.