From edb5126414b0770a2a99b54207d25b192d7f1ff6 Mon Sep 17 00:00:00 2001 From: "Jonathan D.K. Gibbons" Date: Mon, 9 Dec 2019 10:34:20 -0500 Subject: [PATCH] Fix bug in manager.tz parsing. --- src/operations.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/operations.c b/src/operations.c index 2e1ff860..b8ca42be 100644 --- a/src/operations.c +++ b/src/operations.c @@ -314,9 +314,9 @@ static inline bool parse_byte( #define OP_JMPIF(step, cond) if(cond) { state->op_step=step; return true; } // Shortcuts for defining literal-matching states; mostly used for contract-call boilerplate. -#define OP_STEP_REQUIRE_SHORT(constant) { uint16_t val = MICHELSON_READ_SHORT; if(val != constant) PARSE_ERROR(); } OP_STEP -#define OP_STEP_REQUIRE_BYTE(constant) { if(byte != constant) PARSE_ERROR(); } OP_STEP -#define OP_STEP_REQUIRE_LENGTH(constant) { uint32_t val = MICHELSON_READ_LENGTH; if(val != constant) PARSE_ERROR(); } OP_STEP +#define OP_STEP_REQUIRE_SHORT(constant) { uint16_t val = MICHELSON_READ_SHORT; if(val != constant) { PRINTF("Expected: %d, got: %d\n", constant, val); PARSE_ERROR(); } } OP_STEP +#define OP_STEP_REQUIRE_BYTE(constant) { if(byte != constant) { PRINTF("Expected: %d, got: %d\n", constant, byte); PARSE_ERROR(); } } OP_STEP +#define OP_STEP_REQUIRE_LENGTH(constant) { uint32_t val = MICHELSON_READ_LENGTH; if(val != constant) { PARSE_ERROR(); } } OP_STEP switch(state->op_step) { @@ -560,10 +560,12 @@ static inline bool parse_byte( state->argument_length = MICHELSON_READ_LENGTH; } + OP_STEP + // Error on anything but a michelson sequence. OP_STEP_REQUIRE_BYTE(MICHELSON_TYPE_SEQUENCE); - OP_STEP { + { const uint32_t sequence_length = MICHELSON_READ_LENGTH; // Only allow single sequence (5 is needed