From d297a6695168e2f54257283de62f71ae88466eab Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Mon, 3 Oct 2022 13:44:50 +0200 Subject: [PATCH] Enforce proper memory alignment on APDU buffer for response status words --- src_features/signMessageEIP712/commands_712.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src_features/signMessageEIP712/commands_712.c b/src_features/signMessageEIP712/commands_712.c index c1d3a56..dc29b3d 100644 --- a/src_features/signMessageEIP712/commands_712.c +++ b/src_features/signMessageEIP712/commands_712.c @@ -28,7 +28,9 @@ void handle_eip712_return_code(bool success) { } else if (apdu_response_code == APDU_RESPONSE_OK) { // somehow not set apdu_response_code = APDU_RESPONSE_ERROR_NO_INFO; } - *(uint16_t *) G_io_apdu_buffer = __builtin_bswap16(apdu_response_code); + + G_io_apdu_buffer[0] = (apdu_response_code >> 8) & 0xff; + G_io_apdu_buffer[1] = apdu_response_code & 0xff; // Send back the response, do not restart the event loop io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, 2);