aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/mips/mips64/getdents64.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-06-27 15:08:40 +0200
committerFlorian Weimer <fweimer@redhat.com>2019-06-27 15:08:40 +0200
commita620bd7935c4b2dc94e472e62bd9a5c9434ea7b7 (patch)
tree0741388f6c9acdf7621676f6bf4829f0bb7ac44f /sysdeps/unix/sysv/linux/mips/mips64/getdents64.c
parentd039da1c00e01f8d3c3d74f439a971eb73e3045e (diff)
downloadglibc-a620bd7935c4b2dc94e472e62bd9a5c9434ea7b7.zip
glibc-a620bd7935c4b2dc94e472e62bd9a5c9434ea7b7.tar.gz
glibc-a620bd7935c4b2dc94e472e62bd9a5c9434ea7b7.tar.bz2
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>
Diffstat (limited to 'sysdeps/unix/sysv/linux/mips/mips64/getdents64.c')
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/getdents64.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/getdents64.c b/sysdeps/unix/sysv/linux/mips/mips64/getdents64.c
index 1e22fa4..8bf3abb 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/getdents64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/getdents64.c
@@ -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)