Fix pre-encoded data buffer overflow

This commit is contained in:
sekigon-gonnoc 2024-08-24 18:53:51 +09:00
parent fe3b1e2243
commit 2c19e5772d

View file

@ -458,12 +458,13 @@ uint8_t __no_inline_not_in_flash_func(pio_usb_ll_encode_tx_data)(
encoded_data[byte_idx] |= PIO_USB_TX_ENCODED_DATA_COMP;
bit_idx++;
// terminate buffers with K
do {
byte_idx = bit_idx >> 2;
encoded_data[byte_idx] <<= 2;
encoded_data[byte_idx] |= PIO_USB_TX_ENCODED_DATA_K;
bit_idx++;
} while (bit_idx & 0x07);
} while (bit_idx & 0x03);
byte_idx = bit_idx >> 2;
return byte_idx;