diff --git a/fuzzing/extra/apdu_parser.cmake b/fuzzing/extra/apdu_parser.cmake index c3d917259..77f904223 100644 --- a/fuzzing/extra/apdu_parser.cmake +++ b/fuzzing/extra/apdu_parser.cmake @@ -5,7 +5,7 @@ include(${BOLOS_SDK}/fuzzing/libs/lib_standard_app.cmake) # Define the executable and its properties add_executable(fuzz_apdu_parser - ${BOLOS_SDK}/fuzzing/harness/fuzzer_apdu_parser.c) + ${BOLOS_SDK}/fuzzing/harness/fuzzer_apdu_parser.c ${BOLOS_SDK}/lib_alloc/mem_alloc.c) target_compile_options(fuzz_apdu_parser PUBLIC ${COMPILATION_FLAGS}) target_link_options(fuzz_apdu_parser PUBLIC ${LINK_FLAGS}) diff --git a/fuzzing/extra/base58.cmake b/fuzzing/extra/base58.cmake index 2a82c22c8..d5baa9ae2 100644 --- a/fuzzing/extra/base58.cmake +++ b/fuzzing/extra/base58.cmake @@ -4,7 +4,7 @@ include_guard() include(${BOLOS_SDK}/fuzzing/libs/lib_standard_app.cmake) # Define the executable and its properties -add_executable(fuzz_base58 ${BOLOS_SDK}/fuzzing/harness/fuzzer_base58.c) +add_executable(fuzz_base58 ${BOLOS_SDK}/fuzzing/harness/fuzzer_base58.c ${BOLOS_SDK}/lib_alloc/mem_alloc.c) target_compile_options(fuzz_base58 PUBLIC ${COMPILATION_FLAGS}) target_link_options(fuzz_base58 PUBLIC ${LINK_FLAGS}) diff --git a/fuzzing/extra/bip32.cmake b/fuzzing/extra/bip32.cmake index 4d1703dce..2200a3bfe 100644 --- a/fuzzing/extra/bip32.cmake +++ b/fuzzing/extra/bip32.cmake @@ -4,7 +4,7 @@ include_guard() include(${BOLOS_SDK}/fuzzing/libs/lib_standard_app.cmake) # Define the executable and its properties -add_executable(fuzz_bip32 ${BOLOS_SDK}/fuzzing/harness/fuzzer_bip32.c) +add_executable(fuzz_bip32 ${BOLOS_SDK}/fuzzing/harness/fuzzer_bip32.c ${BOLOS_SDK}/lib_alloc/mem_alloc.c) target_compile_options(fuzz_bip32 PUBLIC ${COMPILATION_FLAGS}) target_link_options(fuzz_bip32 PUBLIC ${LINK_FLAGS}) diff --git a/fuzzing/extra/qrcodegen.cmake b/fuzzing/extra/qrcodegen.cmake index 1cdb79a51..f48f752b2 100644 --- a/fuzzing/extra/qrcodegen.cmake +++ b/fuzzing/extra/qrcodegen.cmake @@ -5,7 +5,7 @@ include(${BOLOS_SDK}/fuzzing/mock/mock.cmake) include(${BOLOS_SDK}/fuzzing/libs/lib_qrcode.cmake) # Define the executable and its properties -add_executable(fuzz_qrcodegen ${BOLOS_SDK}/fuzzing/harness/fuzzer_qrcodegen.c) +add_executable(fuzz_qrcodegen ${BOLOS_SDK}/fuzzing/harness/fuzzer_qrcodegen.c ${BOLOS_SDK}/lib_alloc/mem_alloc.c) target_compile_options(fuzz_qrcodegen PUBLIC ${COMPILATION_FLAGS}) target_link_options(fuzz_qrcodegen PUBLIC ${LINK_FLAGS}) diff --git a/fuzzing/mock/mock.cmake b/fuzzing/mock/mock.cmake index 3bc486156..c5190f3b6 100644 --- a/fuzzing/mock/mock.cmake +++ b/fuzzing/mock/mock.cmake @@ -48,6 +48,7 @@ target_compile_options(mock PUBLIC ${COMPILATION_FLAGS} target_include_directories( mock PUBLIC "${BOLOS_SDK}/lib_cxng/include/" + "${BOLOS_SDK}/lib_alloc/" "${BOLOS_SDK}/target/${TARGET}/include/" "${BOLOS_SDK}/lib_standard_app/" "${BOLOS_SDK}/include/" diff --git a/fuzzing/shared_libs/libnbgl_shared_apex_p.a b/fuzzing/shared_libs/libnbgl_shared_apex_p.a index c203ee40b..c4523b549 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_apex_p.a and b/fuzzing/shared_libs/libnbgl_shared_apex_p.a differ diff --git a/fuzzing/shared_libs/libnbgl_shared_flex.a b/fuzzing/shared_libs/libnbgl_shared_flex.a index 1e33d197a..221f4dc9a 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_flex.a and b/fuzzing/shared_libs/libnbgl_shared_flex.a differ diff --git a/fuzzing/shared_libs/libnbgl_shared_nanosp.a b/fuzzing/shared_libs/libnbgl_shared_nanosp.a index ac492cdc8..0938b99d2 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_nanosp.a and b/fuzzing/shared_libs/libnbgl_shared_nanosp.a differ diff --git a/fuzzing/shared_libs/libnbgl_shared_nanox.a b/fuzzing/shared_libs/libnbgl_shared_nanox.a index f74a267ad..b6d5cdf4b 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_nanox.a and b/fuzzing/shared_libs/libnbgl_shared_nanox.a differ diff --git a/fuzzing/shared_libs/libnbgl_shared_stax.a b/fuzzing/shared_libs/libnbgl_shared_stax.a index 15e708f2b..1828eb3ea 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_stax.a and b/fuzzing/shared_libs/libnbgl_shared_stax.a differ diff --git a/include/errors.h b/include/errors.h index 37d75183d..867043bb4 100644 --- a/include/errors.h +++ b/include/errors.h @@ -148,6 +148,6 @@ enum sdk_generic_identifiers { #define EXCEPTION_IO_STATE 0x11 // keep original value // SWO_MUI_UNK_15 #define EXCEPTION_CXPORT 0x12 // keep original value // SWO_MUI_UNK_16 #define EXCEPTION_SYSTEM 0x13 // keep original value // SWO_MUI_UNK_17 -#define EXCEPTION_CORRUPT 0x14 +#define EXCEPTION_CORRUPT 0x14 // dynamic memory corruption detected #endif // ERRORS_H diff --git a/include/nbgl_stubs.h b/include/nbgl_stubs.h index c063ad4f9..2d02329aa 100644 --- a/include/nbgl_stubs.h +++ b/include/nbgl_stubs.h @@ -26,30 +26,31 @@ #define _NR_nbgl_screenHandler 0xa7 #define _NR_nbgl_objPoolGet 0xa8 #define _NR_nbgl_objPoolGetArray 0xa9 -#define _NR_nbgl_containerPoolGet 0xaa -#define _NR_nbgl_getCharWidth 0xab -#define _NR_nbgl_getFont 0xac -#define _NR_nbgl_getFontHeight 0xad -#define _NR_nbgl_getFontLineHeight 0xae -#define _NR_nbgl_getSingleLineTextWidth 0xaf -#define _NR_nbgl_getSingleLineTextWidthInLen 0xb0 -#define _NR_nbgl_getTextHeight 0xb1 -#define _NR_nbgl_getTextHeightInWidth 0xb2 -#define _NR_nbgl_getTextMaxLenAndWidth 0xb3 -#define _NR_nbgl_getTextNbLinesInWidth 0xb4 -#define _NR_nbgl_getTextNbPagesInWidth 0xb5 -#define _NR_nbgl_getTextWidth 0xb6 -#define _NR_nbgl_getTextMaxLenInNbLines 0xb7 -#define _NR_nbgl_textReduceOnNbLines 0xb8 -#define _NR_nbgl_textWrapOnNbLines 0xb9 -#define _NR_nbgl_refreshUnicodeFont 0xba -#define _NR_nbgl_touchHandler 0xbb -#define _NR_nbgl_touchGetTouchDuration 0xbc -#define _NR_nbgl_touchGetTouchedPosition 0xbd -#define _NR_nbgl_buttonsHandler 0xbe -#define _NR_nbgl_buttonsReset 0xbf -#define _NR_nbgl_keyboardCallback 0xc0 -#define _NR_nbgl_keypadCallback 0xc1 -#define _NR_nbgl_drawText 0xc2 -#define _NR_pic_shared 0xc3 -#define _NR_pic_init 0xc4 +#define _NR_nbgl_objPoolStat 0xaa +#define _NR_nbgl_containerPoolGet 0xab +#define _NR_nbgl_getCharWidth 0xac +#define _NR_nbgl_getFont 0xad +#define _NR_nbgl_getFontHeight 0xae +#define _NR_nbgl_getFontLineHeight 0xaf +#define _NR_nbgl_getSingleLineTextWidth 0xb0 +#define _NR_nbgl_getSingleLineTextWidthInLen 0xb1 +#define _NR_nbgl_getTextHeight 0xb2 +#define _NR_nbgl_getTextHeightInWidth 0xb3 +#define _NR_nbgl_getTextMaxLenAndWidth 0xb4 +#define _NR_nbgl_getTextNbLinesInWidth 0xb5 +#define _NR_nbgl_getTextNbPagesInWidth 0xb6 +#define _NR_nbgl_getTextWidth 0xb7 +#define _NR_nbgl_getTextMaxLenInNbLines 0xb8 +#define _NR_nbgl_textReduceOnNbLines 0xb9 +#define _NR_nbgl_textWrapOnNbLines 0xba +#define _NR_nbgl_refreshUnicodeFont 0xbb +#define _NR_nbgl_touchHandler 0xbc +#define _NR_nbgl_touchGetTouchDuration 0xbd +#define _NR_nbgl_touchGetTouchedPosition 0xbe +#define _NR_nbgl_buttonsHandler 0xbf +#define _NR_nbgl_buttonsReset 0xc0 +#define _NR_nbgl_keyboardCallback 0xc1 +#define _NR_nbgl_keypadCallback 0xc2 +#define _NR_nbgl_drawText 0xc3 +#define _NR_pic_shared 0xc4 +#define _NR_pic_init 0xc5 diff --git a/include/os_ux.h b/include/os_ux.h index f0cbb2dcc..5e17f4bc8 100644 --- a/include/os_ux.h +++ b/include/os_ux.h @@ -75,10 +75,6 @@ typedef struct bolos_ux_params_s { /* ----------------------------------------------------------------------- */ /* - UX-RELATED - */ /* ----------------------------------------------------------------------- */ -#if defined(BOLOS_TEST_APDUS_UX) -void bolos_test_ux_apdu(void); -#endif // defined(BOLOS_TEST_APDUS_UX) - // return !0 when ux scenario has ended, else 0 // while not ended, all display/touch/ticker and other events are to be processed by the ux. only io // is not processed. when returning !0 the application must send a general status (or continue its diff --git a/lib_nbgl/include/nbgl_obj.h b/lib_nbgl/include/nbgl_obj.h index 497affa4a..9677a1f8e 100644 --- a/lib_nbgl/include/nbgl_obj.h +++ b/lib_nbgl/include/nbgl_obj.h @@ -708,17 +708,17 @@ void nbgl_objAllowDrawing(bool enable); uint8_t *nbgl_objGetRAMBuffer(void); bool nbgl_objIsUx(nbgl_obj_t *obj); -void nbgl_objPoolRelease(uint8_t layer); +void nbgl_objPoolRelease(nbgl_obj_t *obj); nbgl_obj_t *nbgl_objPoolGet(nbgl_obj_type_t type, uint8_t layer); uint8_t nbgl_objPoolGetId(nbgl_obj_t *obj); int nbgl_objPoolGetArray(nbgl_obj_type_t type, uint8_t nbObjs, uint8_t layer, nbgl_obj_t **objArray); -uint8_t nbgl_objPoolGetNbUsed(uint8_t layer); -void nbgl_containerPoolRelease(uint8_t layer); +void nbgl_containerPoolRelease(nbgl_obj_t **obj); nbgl_obj_t **nbgl_containerPoolGet(uint8_t nbObjs, uint8_t layer); -uint8_t nbgl_containerPoolGetNbUsed(uint8_t layer); +void nbgl_objPoolStat(size_t *allocated_size, uint32_t *nb_allocated); +void nbgl_objPoolReset(void); // for internal use void nbgl_objDrawKeyboard(nbgl_keyboard_t *kbd); diff --git a/src/nbgl_stubs.S b/src/nbgl_stubs.S index 0dbcf4a8e..b3d5654f1 100644 --- a/src/nbgl_stubs.S +++ b/src/nbgl_stubs.S @@ -41,6 +41,7 @@ NBGL_TRAMPOLINE _NR_nbgl_screenReset nbgl_screenReset NBGL_TRAMPOLINE _NR_nbgl_screenHandler nbgl_screenHandler NBGL_TRAMPOLINE _NR_nbgl_objPoolGet nbgl_objPoolGet NBGL_TRAMPOLINE _NR_nbgl_objPoolGetArray nbgl_objPoolGetArray +NBGL_TRAMPOLINE _NR_nbgl_objPoolStat nbgl_objPoolStat NBGL_TRAMPOLINE _NR_nbgl_containerPoolGet nbgl_containerPoolGet NBGL_TRAMPOLINE _NR_nbgl_getCharWidth nbgl_getCharWidth NBGL_TRAMPOLINE _NR_nbgl_getFont nbgl_getFont diff --git a/tests/screenshots/Makefile b/tests/screenshots/Makefile index 73dc689e6..fcc12da9e 100644 --- a/tests/screenshots/Makefile +++ b/tests/screenshots/Makefile @@ -177,6 +177,7 @@ INC:= \ $(SRC_DIR)/uzlib \ $(PUBLIC_SDK_DIR)/target/$(TARGET_PRODUCT_NAME)/include \ $(PUBLIC_SDK_DIR)/include \ + $(PUBLIC_SDK_DIR)/lib_alloc \ $(PUBLIC_SDK_DIR)/lib_ux_nbgl \ $(PUBLIC_SDK_DIR)/lib_cxng/include \ $(PUBLIC_SDK_DIR)/io/include \ @@ -198,6 +199,7 @@ SRCS += $(shell find $(SRC_DIR)/uzlib -type f -name '*.c') SRCS += $(shell find $(SRC_DIR)/main -type f -name '*.c') LIB_SRCS := $(shell find $(NBGL_PATH)/src -type f -name '*.c') LIB_SRCS += $(shell find $(PUBLIC_SDK_DIR)/qrcode/src -type f -name '*.c') +LIB_SRCS += $(PUBLIC_SDK_DIR)/lib_alloc/mem_alloc.c ifneq (, $(filter $(TARGET_DEFINES), SCREEN_SIZE_WALLET)) APP_GLYPHS_PATH := $(APP_PATH)/glyphs/$(APP_ICON_SIZE)/ diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_apex_p.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_apex_p.a index af8f8638f..b4553a4b9 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_apex_p.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_apex_p.a differ diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_flex.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_flex.a index e80c1732d..371406aba 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_flex.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_flex.a differ diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanosp.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanosp.a index 2bc74c89e..24d9fa8ff 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanosp.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanosp.a differ diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanox.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanox.a index 627045f54..d0559cad9 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanox.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanox.a differ diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_stax.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_stax.a index 819b06da1..1119be287 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_stax.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_stax.a differ diff --git a/tests/screenshots/src/main/stubs.c b/tests/screenshots/src/main/stubs.c index fab436a81..adf5b991f 100644 --- a/tests/screenshots/src/main/stubs.c +++ b/tests/screenshots/src/main/stubs.c @@ -292,3 +292,16 @@ void *pic(void *linked_address) { return linked_address; } + +//=================================================== +// Exception-related functions. Exceptions are not handled, functions are just defined so that tests +// can compile. +try_context_t *try_context_get(void) +{ + return NULL; +} + +void os_longjmp(uint32_t exception) +{ + longjmp(try_context_get()->jmp_buf, exception); +}