summaryrefslogtreecommitdiff
path: root/atmel-samd
diff options
context:
space:
mode:
authorScott Shawcroft <scott@chickadee.tech>2017-07-13 16:21:12 -0700
committerScott Shawcroft <scott@chickadee.tech>2017-07-13 16:21:12 -0700
commitc82b84e0a92575f01fbfda0713c8906745357155 (patch)
treee2159a91cf266a54dc9d43214c5662839be4555a /atmel-samd
parent3660023046a19b075165ad57e1529a57f3383b8c (diff)
atmel-samd: Fix potential buffer overflow in UART.c by recalculating
the buffer end rather than naively adding 1. It could have needed to wrap around. Thanks @dhalbert for spotting the bug. Fixes #132
Diffstat (limited to 'atmel-samd')
-rw-r--r--atmel-samd/common-hal/busio/UART.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/atmel-samd/common-hal/busio/UART.c b/atmel-samd/common-hal/busio/UART.c
index c682a14be..f172a1ecc 100644
--- a/atmel-samd/common-hal/busio/UART.c
+++ b/atmel-samd/common-hal/busio/UART.c
@@ -105,8 +105,9 @@ static void _busio_uart_interrupt_handler(uint8_t instance)
self->buffer_size++;
if (module->character_size == USART_CHARACTER_SIZE_9BIT) {
+ buffer_end = (self->buffer_start + self->buffer_size) % self->buffer_length;
/* 9-bit data, write next received byte to the buffer */
- self->buffer[buffer_end + 1] = (received_data >> 8);
+ self->buffer[buffer_end] = (received_data >> 8);
self->buffer_size++;
}