From 555c32015c59929dce4b46b38a383c6d4760174d Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Mon, 14 Feb 2011 13:23:39 +0000 Subject: [PATCH] uart: prevent from retrieving more than buffer length (potential buffer overflow) --- libnfc/buses/uart_posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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