From 3faa172ec2748f655c64444c624a0b08739045ad Mon Sep 17 00:00:00 2001 From: pscott Date: Thu, 15 Apr 2021 15:36:21 +0200 Subject: [PATCH] Add MAX and MIN tx types --- src_common/ethUstream.c | 6 +++++- src_common/ethUstream.h | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src_common/ethUstream.c b/src_common/ethUstream.c index a97a418..18cd896 100644 --- a/src_common/ethUstream.c +++ b/src_common/ethUstream.c @@ -265,9 +265,13 @@ static parserStatus_e processTxInternal(txContext_t *context) { } // EIP 2718: TransactionType might be present before the TransactionPayload. if (*context->workBuffer > 0x00 && *context->workBuffer < 0x7f) { + PRINTF("TX TYPE: %u\n", context->txType); + if (*context->workBuffer < MIN_TX_TYPE || *context->workBuffer > MAX_TX_TYPE ) { + PRINTF("Transaction type not supported\n"); + return USTREAM_FAULT; + } context->txType = *context->workBuffer; context->workBuffer++; - PRINTF("TX TYPE: %u\n", context->txType); } if (!context->processingField) { PRINTF("PROCESSING FIELD\n"); diff --git a/src_common/ethUstream.h b/src_common/ethUstream.h index 24cbaa0..cd30835 100644 --- a/src_common/ethUstream.h +++ b/src_common/ethUstream.h @@ -55,8 +55,10 @@ typedef enum rlpTxField_e { // EIP 2718 TransactionType typedef enum txType_e { - LegacyTransaction = 1, - BerlinTransaction = 2 + MIN_TX_TYPE, + LEGACY_TX, + BERLIN_TX, + MAX_TX_TYPE, } txType_e; typedef enum parserStatus_e {