aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/mips
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/mips')
-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 1e22fa4325..8bf3abb0e0 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)