Enforce proper memory alignment on APDU buffer for response status words

This commit is contained in:
Alexandre Paillier
2022-10-03 13:44:50 +02:00
parent fe3f61c7a0
commit d297a66951

View File

@@ -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);