diff --git a/libnfc/buses/uart_posix.c b/libnfc/buses/uart_posix.c index f21e948..8e664c9 100644 --- a/libnfc/buses/uart_posix.c +++ b/libnfc/buses/uart_posix.c @@ -252,7 +252,7 @@ uart_receive (serial_port sp, byte_t * pbtRx, size_t * pszRx) return DEIO; } // There is something available, read the data - res = read (((serial_port_unix *) sp)->fd, pbtRx + (*pszRx), byteCount); + res = read (((serial_port_unix *) sp)->fd, pbtRx + (*pszRx), MIN(byteCount, iExpectedByteCount)); iExpectedByteCount -= byteCount; // Stop if the OS has some troubles reading the data