mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Linux: Adjust gedents64 buffer size to int range [BZ #24740]
The kernel interface uses type unsigned int, but there is an internal conversion to int, so INT_MAX is the correct limit. Part of the buffer will always be unused, but this is not a problem. Such huge buffers do not occur in practice anyway. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
@ -23,12 +23,18 @@
|
||||
#include <sys/param.h>
|
||||
#include <unistd.h>
|
||||
#include <scratch_buffer.h>
|
||||
#include <limits.h>
|
||||
|
||||
ssize_t
|
||||
__getdents64 (int fd, void *buf0, size_t nbytes)
|
||||
{
|
||||
char *buf = buf0;
|
||||
|
||||
/* The system call takes an unsigned int argument, and some length
|
||||
checks in the kernel use an int type. */
|
||||
if (nbytes > INT_MAX)
|
||||
nbytes = INT_MAX;
|
||||
|
||||
#ifdef __NR_getdents64
|
||||
ssize_t ret = INLINE_SYSCALL_CALL (getdents64, fd, buf, nbytes);
|
||||
if (ret != -1)
|
||||
|
Reference in New Issue
Block a user