Merge pull request from GHSA-7pg2-p5vj-xp5h

Shift operation expect the shift amount to be an unsigned int 256, even
though only 8 bits provides meaningful value. Besu optimized this by
casting this to an int, but it was signed, resulting in a bad shift
amount. To ensure that such errors don't cause issues again test the
binary data types as a potentially negative along the major int
types (8,16,32,64,128,256).

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
pull/3161/head
Danno Ferrin 3 years ago committed by GitHub
parent f2893bd18f
commit 9c23c45ebf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 60
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/SarOperationTest.java
  2. 30
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShlOperationTest.java
  3. 30
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShrOperationTest.java

@ -143,6 +143,66 @@ public class SarOperationTest {
"0x100",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x80",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x8000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x80000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x8000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x80000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x8000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x8000000000000000000000000000000000000000000000000000000000000400",
"0x80",
"0xffffffffffffffffffffffffffffffff80000000000000000000000000000000"
},
{
"0x8000000000000000000000000000000000000000000000000000000000000400",
"0x8000",
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"0x8000000000000000000000000000000000000000000000000000000000000400",
"0x80000000",
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"0x8000000000000000000000000000000000000000000000000000000000000400",
"0x8000000000000000",
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"0x8000000000000000000000000000000000000000000000000000000000000400",
"0x80000000000000000000000000000000",
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"0x8000000000000000000000000000000000000000000000000000000000000400",
"0x8000000000000000000000000000000000000000000000000000000000000000",
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
};
@Parameterized.Parameters(name = "{index}: {0}, {1}, {2}")

@ -92,6 +92,36 @@ public class ShlOperationTest {
"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"0x01",
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x80",
"0x0000000000000000000000000000040000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x8000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x80000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x8000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x80000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x8000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
}
};

@ -112,6 +112,36 @@ public class ShrOperationTest {
"0x01",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x80",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x8000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x80000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x8000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x80000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"0x0000000000000000000000000000000000000000000000000000000000000400",
"0x8000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
}
};
@Parameterized.Parameters(name = "{index}: {0}, {1}, {2}")

Loading…
Cancel
Save