Skip to content

Commit 59ad1ae

Browse files
Merge pull request #132 from sekigon-gonnoc/fix/buffer-overflow
Fix pre-encoded data buffer overflow
2 parents 7902e9f + dddb76b commit 59ad1ae

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/pio_usb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,13 @@ uint8_t __no_inline_not_in_flash_func(pio_usb_ll_encode_tx_data)(
458458
encoded_data[byte_idx] |= PIO_USB_TX_ENCODED_DATA_COMP;
459459
bit_idx++;
460460

461+
// terminate buffers with K
461462
do {
462463
byte_idx = bit_idx >> 2;
463464
encoded_data[byte_idx] <<= 2;
464465
encoded_data[byte_idx] |= PIO_USB_TX_ENCODED_DATA_K;
465466
bit_idx++;
466-
} while (bit_idx & 0x07);
467+
} while (bit_idx & 0x03);
467468

468469
byte_idx = bit_idx >> 2;
469470
return byte_idx;

0 commit comments

Comments
 (0)