From 3d178a7e2b75066593fbd5705742c5808395d90d Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 28 Jun 2019 17:58:03 -0400 Subject: cap getdents length argument to INT_MAX the linux syscall treats this argument as having type int, so passing extremely long buffer sizes would be misinterpreted by the kernel. since "short reads" are always acceptable, just cap it down. patch based on report and suggested change by Florian Weimer. --- src/linux/getdents.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/linux/getdents.c b/src/linux/getdents.c index de6de3b4..796c1e5c 100644 --- a/src/linux/getdents.c +++ b/src/linux/getdents.c @@ -1,9 +1,11 @@ #define _BSD_SOURCE #include +#include #include "syscall.h" int getdents(int fd, struct dirent *buf, size_t len) { + if (len>INT_MAX) len = INT_MAX; return syscall(SYS_getdents, fd, buf, len); } -- cgit v1.2.1