Skip to content
Browse files

interfaces/kiss: fix KISS interface MTU check on RX

`driver->rx_packet` holds each (temporally incomplete) incoming CSP packet,
while `driver->rx_length` has said buffer's valid number of bytes.

As `interface->mtu` only applies to CSP "data" (and `driver->rx_packet` is
filled from `driver->rx_packet->id.ext`, not `driver->rx_packet->data`), size
checks must take `CSP_HEADER_LENGTH` into account.

Whatsmore, when "End char" is processed, this is correctly being handled, as
evidenced by the following snippet:

/* The CSP packet length is without the header */
driver->rx_packet->length = driver->rx_length - CSP_HEADER_LENGTH;
  • Loading branch information...
Matias Devenuta
Matias Devenuta committed Apr 12, 2019
1 parent 5235fb4 commit 5cb1dc6ebb5bbfa15dac822d607de6c87736b497
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/interfaces/csp_if_kiss.c
@@ -101,7 +101,7 @@ void csp_kiss_rx(csp_iface_t * interface, uint8_t * buf, int len, void * pxTaskW
unsigned char inputbyte = *buf++;

/* If packet was too long */
if (driver->rx_length > interface->mtu) {
if (driver->rx_length > interface->mtu + CSP_HEADER_LENGTH) {
csp_log_warn("KISS RX overflow");
driver->rx_mode = KISS_MODE_NOT_STARTED;

0 comments on commit 5cb1dc6

Please sign in to comment.
You can’t perform that action at this time.