From a00fe3a059ef361856a0fec4d9ba80848f6535f9 Mon Sep 17 00:00:00 2001 From: Ajinkya Rajandekar Date: Mon, 12 Feb 2024 16:17:32 +0000 Subject: [PATCH] Fix unsigned int treated as int. --- app/src/parser/operation_parser.c | 4 ++-- app/src/parser/operation_state.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/parser/operation_parser.c b/app/src/parser/operation_parser.c index 8fbf23552..40bf2420c 100644 --- a/app/src/parser/operation_parser.c +++ b/app/src/parser/operation_parser.c @@ -419,7 +419,7 @@ tz_step_size(tz_parser_state *state) } op->frame->step_size.size = (op->frame->step_size.size << 8) | b; op->frame->step_size.size_len--; - if (op->frame->step_size.size_len <= 0) { + if (op->frame->step_size.size_len == 0) { op->frame[-1].stop = state->ofs + op->frame->step_size.size; tz_must(pop_frame(state)); } @@ -590,7 +590,7 @@ tz_step_read_int32(tz_parser_state *state) ASSERT_STEP(state, READ_INT32); tz_operation_state *op = &state->operation; uint8_t b; - uint32_t *value = &op->frame->step_read_int32.value; + int32_t *value = &op->frame->step_read_int32.value; if (op->frame->step_read_int32.ofs < 4) { tz_must(tz_parser_read(state, &b)); *value = (*value << 8) | b; diff --git a/app/src/parser/operation_state.h b/app/src/parser/operation_state.h index a9ec5efa8..eae58b6dd 100644 --- a/app/src/parser/operation_state.h +++ b/app/src/parser/operation_state.h @@ -147,8 +147,8 @@ typedef struct { uint8_t skip : 1, natural : 1; } step_read_num; struct { - uint32_t value; - uint8_t skip : 1, ofs : 3; + int32_t value; + uint8_t skip : 1, ofs : 3; } step_read_int32; struct { uint16_t ofs;