uart: prevent from retrieving more than buffer length (potential buffer overflow)
This commit is contained in:
parent
287bbfeea3
commit
555c32015c
1 changed files with 1 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue