Skip to content

Commit ca16408

Browse files
authored
Merge pull request #50 from Zondax/tx_rejected
Tx rejected
2 parents 88fefcd + c39778c commit ca16408

29 files changed

Lines changed: 1332 additions & 253 deletions

File tree

.gdbinit

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://www.jetbrains.com/help/clion/configuring-debugger-options.html#gdbinit-lldbinit
2+
#
3+
# You need to create `$HOME/.gdbinit` with the following content:
4+
# set auto-load local-gdbinit on
5+
# add-auto-load-safe-path /
6+
7+
set architecture arm
8+
handle SIGILL nostop pass noprint
9+
add-symbol-file app/bin/app.elf 0x40000000
10+
set backtrace limit 20
11+
b *0x40000000

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ string(APPEND CMAKE_LINKER_FLAGS " -fsanitize=address -fno-omit-frame-pointer")
3030
##############################################################
3131
# static libs
3232
file(GLOB_RECURSE TINYCBOR_SRC
33-
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src/cborparser.c
34-
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src/cborvalidation.c
33+
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor-ledger/cborparser.c
34+
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor-ledger/cborvalidation.c
3535
)
3636

3737
file(GLOB_RECURSE LIB_SRC
@@ -68,7 +68,7 @@ target_compile_definitions(app_val_lib PRIVATE APP_VALIDATOR)
6868

6969
target_include_directories(app_lib PUBLIC
7070
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/include
71-
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src
71+
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor-ledger
7272
${CMAKE_CURRENT_SOURCE_DIR}/deps/sha512
7373
${CMAKE_CURRENT_SOURCE_DIR}/app/src
7474
${CMAKE_CURRENT_SOURCE_DIR}/app/src/consumer
@@ -105,7 +105,7 @@ target_include_directories(unittests PUBLIC
105105
${gmock_SOURCE_DIR}/include
106106
${CONAN_INCLUDE_DIRS_FMT}
107107
${CONAN_INCLUDE_DIRS_JSONCPP}
108-
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src
108+
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor-ledger
109109
${CMAKE_CURRENT_SOURCE_DIR}/tests/utils
110110
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/include
111111
)

app/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ endif
2222

2323
MY_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
2424

25+
ifeq ($(APP_TESTING),1)
26+
DEFINES += APP_TESTING
27+
DEFINES += ZEMU_LOGGING
28+
endif
29+
2530
all: bin/app.elf
2631
@echo "#!/usr/bin/env bash" > $(CURDIR)/pkg/zxtool.sh
2732
@echo "APPNAME=\"${APPNAME}\"" >> $(CURDIR)/pkg/zxtool.sh
@@ -36,15 +41,15 @@ all: bin/app.elf
3641
@chmod +x $(CURDIR)/pkg/zxtool.sh
3742

3843
include $(BOLOS_SDK)/Makefile.defines
39-
#DEFINES += ZEMU_LOGGING
44+
DEFINES += NDEBUG
4045

4146
ifndef COIN
4247
COIN=oasis
4348
endif
4449

4550
APPVERSION_M=1
4651
APPVERSION_N=5
47-
APPVERSION_P=0
52+
APPVERSION_P=1
4853

4954
$(info COIN = [$(COIN)])
5055
ifeq ($(COIN),oasis)
@@ -123,7 +128,7 @@ DEFINES += HAVE_UX_FLOW
123128

124129
else
125130
# Assume Nano S
126-
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=64
131+
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
127132
DEFINES += HAVE_BOLOS_UX COMPLIANCE_UX_160 HAVE_UX_LEGACY HAVE_UX_FLOW
128133
endif
129134

app/script_con.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ MEMORY
3030
}
3131

3232
PAGE_SIZE = 64;
33-
STACK_SIZE = 2448;
33+
STACK_SIZE = 2392;
3434
END_STACK = ORIGIN(SRAM) + LENGTH(SRAM);
3535

3636
SECTIONS

app/src/common/parser_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ typedef enum {
3636
parser_display_page_out_of_range,
3737
parser_unexepected_error,
3838
// Coin generic
39+
parser_root_item_should_be_a_map,
3940
parser_unexpected_type,
4041
parser_unexpected_method,
4142
parser_unexpected_buffer_end,
@@ -61,6 +62,7 @@ typedef enum {
6162
// Required fields
6263
parser_required_nonce,
6364
parser_required_method,
65+
parser_required_body,
6466
// Amino related
6567
parser_unexpected_wire_type,
6668
parser_unexpected_round_value,

app/src/consumer/cbor_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ __Z_INLINE parser_error_t parser_mapCborError(CborError err) {
3232

3333
#define CHECK_CBOR_ERR(CALL) { \
3434
CborError err = CALL; \
35+
check_app_canary(); \
3536
if (err!=CborNoError) return parser_mapCborError(err);}
3637

3738
#define CHECK_CBOR_TYPE(type, expected) {if (type!=expected) return parser_unexpected_type;}

app/src/consumer/parser_consumer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ void __assert_fail(const char * assertion, const char * file, unsigned int line,
3636
parser_error_t parser_parse(parser_context_t *ctx, const uint8_t *data, size_t dataLen) {
3737
CHECK_PARSER_ERR(parser_init(ctx, data, dataLen))
3838
CHECK_PARSER_ERR(_readContext(ctx, &parser_tx_obj))
39-
return _read(ctx, &parser_tx_obj);
39+
CHECK_PARSER_ERR(_read(ctx, &parser_tx_obj));
40+
CHECK_PARSER_ERR(_extractContextSuffix(&parser_tx_obj))
41+
return parser_ok;
4042
}
4143

4244
parser_error_t parser_validate(const parser_context_t *ctx) {

0 commit comments

Comments
 (0)