提交 3d178a7e 编写于 作者: R Rich Felker

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.
上级 54b7564b
#define _BSD_SOURCE #define _BSD_SOURCE
#include <dirent.h> #include <dirent.h>
#include <limits.h>
#include "syscall.h" #include "syscall.h"
int getdents(int fd, struct dirent *buf, size_t len) int getdents(int fd, struct dirent *buf, size_t len)
{ {
if (len>INT_MAX) len = INT_MAX;
return syscall(SYS_getdents, fd, buf, len); return syscall(SYS_getdents, fd, buf, len);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册