libosmocore/src
Vadim Yanitskiy d76cc3704e soft_uart: fix the Rx flushing logic, add a unit test
Coverity tells us that with the current logic it's possible (in theory)
that we may dereference NULL pointer in osmo_soft_uart_flush_rx().  This
is highly unlikely, because the Rx buffer gets allocated once when the
Rx is enabled and remains even after the Rx gets disabled.  The Rx flags
cannot be anything than 0x00 before the Rx gets enabled.

Even though this NULL pointer dereference is unlikely, the Rx flushing
logic is still not entirely correct.  As can be seen from the unit test
output, the Rx callback of the application may be called with an empty
msgb if the following conditions are both met:

a) the osmo_soft_uart_flush_rx() is invoked manually, and
b) a parity and/or a framing error has occurred previously.

We should not be checking suart->rx.flags in osmo_soft_uart_flush_rx(),
since this is already done in suart_rx_ch(), which is calling it.
Removing this check also eliminates a theoretical possibility of the
NULL pointer dereference, so we're killing two birds with one stone.

- Do not check suart->rx.flags in osmo_soft_uart_flush_rx().
- Add a unit test for various flush()ing scenarios.

Change-Id: I5179f5fd2361e4e96ac9bf48e80b99e53a7e4712
Fixes: CID#336545
2023-12-11 20:49:24 +00:00
..
codec Bump version: 1.8.0.252-13c29 → 1.9.0 2023-09-12 13:15:54 +02:00
coding coding: gsm0503_pdtch_decode(): implement USF decoding for CS1 2023-12-08 03:35:57 +07:00
core soft_uart: fix the Rx flushing logic, add a unit test 2023-12-11 20:49:24 +00:00
ctrl Bump version: 1.8.0.252-13c29 → 1.9.0 2023-09-12 13:15:54 +02:00
gb Bump version: 1.8.0.252-13c29 → 1.9.0 2023-09-12 13:15:54 +02:00
gsm gsup: fix error log message 2023-12-05 18:36:29 +00:00
isdn LAPD: Indicate sequence error after indicating received data 2023-11-27 16:25:53 +00:00
pseudotalloc Fix all references to config.h 2023-01-18 19:04:36 +01:00
sim libosmosim: Support Microsoft smart card discovery process 2023-11-28 22:50:01 +01:00
usb Fix all references to config.h 2023-01-18 19:04:36 +01:00
vty Bump version: 1.8.0.252-13c29 → 1.9.0 2023-09-12 13:15:54 +02:00
Makefile.am create libosmoisdn sub-library 2023-01-21 22:41:57 +01:00