musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/linux/getdents.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019年06月28日 17:58:03 -0400
committerRich Felker <dalias@aerifal.cx>2019年06月28日 17:58:03 -0400
commit3d178a7e2b75066593fbd5705742c5808395d90d (patch)
treeda5f36fbd4c0508a62eca103c77bf2db7b15e15b /src/linux/getdents.c
parent54b7564b72c1edcc79fca083047521fb56eaea00 (diff)
downloadmusl-3d178a7e2b75066593fbd5705742c5808395d90d.tar.gz
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.
Diffstat (limited to 'src/linux/getdents.c')
-rw-r--r--src/linux/getdents.c 2
1 files changed, 2 insertions, 0 deletions
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 <dirent.h>
+#include <limits.h>
#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);
}
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月20日 01:27:15 +0000

AltStyle によって変換されたページ (->オリジナル) /