coreutils: Fix implementation of `struct __sFILE`

Remove unnecessary mitigation.
This commit is contained in:
Tee KOBAYASHI 2022-09-28 19:22:31 +09:00 committed by xtkoba
parent 65e3f97b5a
commit ed021c2bb0
3 changed files with 23 additions and 38 deletions

View File

@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Basic file, shell and text manipulation utilities from t
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=9.1
TERMUX_PKG_REVISION=1
TERMUX_PKG_REVISION=2
TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/coreutils/coreutils-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=61a1f410d78ba7e7f37a5a4f50e6d1320aca33375484a3255eddf17a38580423
TERMUX_PKG_DEPENDS="libandroid-support, libgmp, libiconv"

View File

@ -1,37 +0,0 @@
See https://github.com/termux/termux-packages/issues/11912.
--- a/lib/fflush.c
+++ b/lib/fflush.c
@@ -231,3 +231,32 @@
}
#endif
}
+
+#if defined __ANDROID__ && !defined __LP64__
+
+#include <dlfcn.h>
+
+typedef ssize_t (*write_impl_t)(int, const void *, size_t);
+
+ssize_t
+write(int __fd, const void *__buf, size_t __count)
+{
+ static int initialized = 0;
+ static write_impl_t libc_impl = NULL;
+
+ if (!initialized) {
+ libc_impl = dlsym(RTLD_NEXT, "write");
+ initialized = 1;
+ }
+
+ /* This should not normally happen. */
+ if ((uint64_t)__buf + (uint64_t)__count == (1ULL << 32))
+ return (ssize_t)__count;
+
+ if (libc_impl != NULL)
+ return libc_impl(__fd, __buf, __count);
+
+ __builtin_abort();
+}
+
+#endif

View File

@ -0,0 +1,22 @@
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -68,8 +68,10 @@
# elif defined __ANDROID__ /* Android */
# ifdef __LP64__
# define _gl_flags_file_t int
+# define _gl_struct_file_off_t int64_t
# else
# define _gl_flags_file_t short
+# define _gl_struct_file_off_t __kernel_off_t
# endif
/* Up to this commit from 2015-10-12
<https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
@@ -96,7 +98,7 @@
unsigned char _nbuf[1]; \
struct { unsigned char *_base; size_t _size; } _lb; \
int _blksize; \
- fpos_t _offset; \
+ _gl_struct_file_off_t _offset; \
/* More fields, not relevant here. */ \
} *) fp)
# else