Skip to content

Commit 4ee92f2

Browse files
committed
core/types: reject Metro receipts with > 0x01 status bytes
1 parent 79bf69b commit 4ee92f2

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎core/types/receipt.go‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,21 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error {
108108
}
109109
// Deserialize based on the first component type.
110110
switch {
111-
case kind == rlp.Byte || kind == rlp.String && len(cnt) == 0:
112-
// The first component of metropolis receipts is Byte
113-
// or empty String(byte with 0x00 value).
111+
case kind == rlp.Byte || (kind == rlp.String && len(cnt) == 0):
112+
// The first component of metropolis receipts is Byte (0x01), or the empty
113+
// string (0x80, decoded as a byte with 0x00 value).
114114
var metro metropolisReceiptRLP
115115
if err := rlp.DecodeBytes(raw, &metro); err != nil {
116116
return err
117117
}
118-
r.Failed = metro.Status == receiptStatusFailed
118+
switch metro.Status {
119+
case receiptStatusSuccessful:
120+
r.Failed = false
121+
case receiptStatusFailed:
122+
r.Failed = true
123+
default:
124+
return fmt.Errorf("invalid status byte: 0x%x", metro.Status)
125+
}
119126
r.CumulativeGasUsed = metro.CumulativeGasUsed
120127
r.Bloom = metro.Bloom
121128
r.Logs = metro.Logs

0 commit comments

Comments
 (0)