[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] stdio-impl.h: Fix type of _offset field for Android
From: |
Tee KOBAYASHI |
Subject: |
[PATCH] stdio-impl.h: Fix type of _offset field for Android |
Date: |
Thu, 29 Sep 2022 09:51:34 +0900 |
On 32-bit Android fpos_t becomes a 64-bit type when large-file support
is enabled, whereas _offset remains 32-bit. Out-of-bounds read/write
could happen when _offset field is accessed in this situation.
---
lib/stdio-impl.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index ed32e69..1384b8e 100644
--- 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
--
2.36.1
- [PATCH] stdio-impl.h: Fix type of _offset field for Android,
Tee KOBAYASHI <=