Skip to content

Commit c82b84e

Browse files
committed
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 adafruit#132
1 parent 3660023 commit c82b84e

File tree

1 file changed

+2
-1
lines changed
  • atmel-samd/common-hal/busio

1 file changed

+2
-1
lines changed

atmel-samd/common-hal/busio/UART.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ static void _busio_uart_interrupt_handler(uint8_t instance)
105105
self->buffer_size++;
106106

107107
if (module->character_size == USART_CHARACTER_SIZE_9BIT) {
108+
buffer_end = (self->buffer_start + self->buffer_size) % self->buffer_length;
108109
/* 9-bit data, write next received byte to the buffer */
109-
self->buffer[buffer_end + 1] = (received_data >> 8);
110+
self->buffer[buffer_end] = (received_data >> 8);
110111
self->buffer_size++;
111112
}
112113

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy