summaryrefslogtreecommitdiff
path: root/libc/unistd
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2019-06-21 12:09:36 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2019-06-21 12:09:36 +0200
commit4f506bb95ad4bc55e6174cef98803802a35b050e (patch)
treeb6e7adaf2b8c6b2d7cdb3dba03d87062e7e39e27 /libc/unistd
parentf93b43e4d1a02b72e8e7659f6be4cc28a0c6e194 (diff)
fix opendir, fpathconf and ttyname_r to use fstat64(), not fstat()
There is no opendir64(), thus even programs built for 64-bit off_t use opendir(). Before this change, internally opendir() uses fstat(), with the following breakage if some of struct stat fields are too narrow: $ strace ls -l execve("/busybox/ls", ["ls", "-l"], 0x7ffcdc43ede8 /* 16 vars */) = 0 ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0 getuid32() = 0 time([1551486393 /* 2019-03-02T00:26:33+0000 */]) = 1551486393 (2019-03-02T00:26:33+0000) ioctl(0, TIOCGWINSZ, {ws_row=38, ws_col=120, ws_xpixel=0, ws_ypixel=0}) = 0 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0 brk(NULL) = 0x9768000 brk(0x9769000) = 0x9769000 lstat64(".", 0xffa6e374) = 0 open(".", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3 fstat(3, 0xffa6e378) = -1 EOVERFLOW (Value too large for defined data type) See https://bugs.busybox.net/show_bug.cgi?id=11651 Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'libc/unistd')
-rw-r--r--libc/unistd/fpathconf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libc/unistd/fpathconf.c b/libc/unistd/fpathconf.c
index 556343be2..82c34c4da 100644
--- a/libc/unistd/fpathconf.c
+++ b/libc/unistd/fpathconf.c
@@ -24,6 +24,8 @@
#include <sys/stat.h>
#include <sys/statfs.h>
+#define STAT stat64
+#define FSTAT fstat64
#ifndef __USE_FILE_OFFSET64
extern int fstatfs (int __fildes, struct statfs *__buf)
@@ -205,9 +207,9 @@ long int fpathconf(int fd, int name)
#if defined _POSIX_ASYNC_IO
{
/* AIO is only allowed on regular files and block devices. */
- struct stat st;
+ struct STAT st;
- if (fstat (fd, &st) < 0 || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
+ if (FSTAT (fd, &st) < 0 || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
return -1;
else
return 1;