[Bug] XAP: Fix unaligned memory access in config blob handler and USB task loop condition (#18612)

* Fix unaligned memory access in config blob handler

data* points in the middle of an u8 array, casting this to an u16* and
dereferencing it leads to an unaligned memory access - which hardfaults
on Cortex M0 mcus e.g. RP2040s.

* Actually read until there is no more data to be read
This commit is contained in:
Stefan Kerkmann 2022-10-05 21:26:53 +02:00 committed by GitHub
parent d479eaf2d6
commit 907640e40e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -64,7 +64,8 @@ bool xap_respond_get_config_blob_chunk(xap_token_t token, const void *data, size
return false;
}
uint16_t offset = *((uint16_t *)data);
uint16_t offset;
memcpy(&offset, data, sizeof(uint16_t));
xap_route_qmk_config_blob_chunk_t ret = {0};

View File

@ -1165,7 +1165,7 @@ void xap_task(void) {
uint8_t buffer[XAP_EPSIZE];
size_t size = 0;
do {
size_t size = chnReadTimeout(&drivers.xap_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE);
size = chnReadTimeout(&drivers.xap_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE);
if (size > 0) {
xap_receive_base(buffer);
}