mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
* debug/recv_chk.c (__recv_chk): Always fail if request could
overflow the buffer. * debug/recvfrom_chk.c (__recvfrom_chk): Likewise.
This commit is contained in:
@ -23,11 +23,8 @@
|
||||
ssize_t
|
||||
__recv_chk (int fd, void *buf, size_t n, size_t buflen, int flags)
|
||||
{
|
||||
/* In case N is greater than BUFLEN, we read BUFLEN+1 bytes.
|
||||
This might overflow the buffer but the damage is reduced to just
|
||||
one byte. And the program will terminate right away. */
|
||||
ssize_t nrecv = __recv (fd, buf, MIN (n, buflen + 1), flags);
|
||||
if (nrecv > 0 && (size_t) nrecv > buflen)
|
||||
if (n > buflen)
|
||||
__chk_fail ();
|
||||
return nrecv;
|
||||
|
||||
return __recv (fd, buf, n, flags);
|
||||
}
|
||||
|
Reference in New Issue
Block a user