mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-03-17 04:53:47 +00:00
uart: prevent from retrieving more than buffer length (potential buffer overflow)
This commit is contained in:
@@ -252,7 +252,7 @@ uart_receive (serial_port sp, byte_t * pbtRx, size_t * pszRx)
|
|||||||
return DEIO;
|
return DEIO;
|
||||||
}
|
}
|
||||||
// There is something available, read the data
|
// 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;
|
iExpectedByteCount -= byteCount;
|
||||||
|
|
||||||
// Stop if the OS has some troubles reading the data
|
// Stop if the OS has some troubles reading the data
|
||||||
|
|||||||
Reference in New Issue
Block a user