1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/xbee: prevent 0 length packet sent to UART

Since the API doc doesn't specify what to do with 0
len writings into UART, we cannot assume that is
safe to do it, so this commit prevents it by checking
the length prior to the `uart_write()` operation.
This commit is contained in:
kYc0o 2019-04-02 16:47:13 +02:00
parent 299a1903e6
commit f673d5af1e

View File

@ -664,7 +664,9 @@ static int xbee_send(netdev_t *dev, const iolist_t *iolist)
DEBUG("[xbee] send: now sending out %i byte\n", (int)size);
mutex_lock(&(xbee->tx_lock));
for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) {
uart_write(xbee->p.uart, iol->iol_base, iol->iol_len);
if (iol->iol_len > 0) {
uart_write(xbee->p.uart, iol->iol_base, iol->iol_len);
}
}
uart_write(xbee->p.uart, &csum, 1);
mutex_unlock(&(xbee->tx_lock));