Match __bos0 to __pass_object_size0 in FORTIFY
pass_object_size(N) forwards the result of __builtin_object_size(param,
N) to a function. So, a function that looks like:
size_t foo(void *const p __pass_object_size) { return __bos0(p); }
int bar = foo(baz);
would effectively be turned into
size_t foo(void *const p, size_t sz) { return sz; }
int bar = foo(baz, __bos(baz)); // note that this is not __bos0
This is bad, since if we're using __bos0, we want more relaxed
objectsize checks.
__bos0 should be more permissive than __bos in all cases, so this
change Should Be Fineā¢.
This change also makes GCC and clang share another function's
implementation (recv). I just realized we need to add special
diagnostic-related overloads bits for clang to it, but I can do that in
another patch.
Bug: None
Test: Bullhead builds and boots; CtsBionicTestCases passes.
Change-Id: I6818d0041328ab5fd0946a1e57321a977c1e1250
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index b3f8c11..7c6125a 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -322,7 +322,7 @@
__error_if_overflows_objectsize(count, __bos0(buf));
__BIONIC_FORTIFY_INLINE
-ssize_t pread(int fd, void* const __pass_object_size buf, size_t count,
+ssize_t pread(int fd, void* const __pass_object_size0 buf, size_t count,
off_t offset) __overloadable {
size_t bos = __bos0(buf);
@@ -343,7 +343,7 @@
__error_if_overflows_objectsize(count, __bos0(buf));
__BIONIC_FORTIFY_INLINE
-ssize_t pread64(int fd, void* const __pass_object_size buf, size_t count,
+ssize_t pread64(int fd, void* const __pass_object_size0 buf, size_t count,
off64_t offset) __overloadable {
size_t bos = __bos0(buf);
@@ -368,7 +368,7 @@
__error_if_overflows_objectsize(count, __bos0(buf));
__BIONIC_FORTIFY_INLINE
-ssize_t pwrite(int fd, const void* const __pass_object_size buf, size_t count,
+ssize_t pwrite(int fd, const void* const __pass_object_size0 buf, size_t count,
off_t offset) __overloadable {
size_t bos = __bos0(buf);
@@ -391,8 +391,8 @@
__error_if_overflows_objectsize(count, __bos0(buf));
__BIONIC_FORTIFY_INLINE
-ssize_t pwrite64(int fd, const void* const __pass_object_size buf, size_t count,
- off64_t offset) __overloadable {
+ssize_t pwrite64(int fd, const void* const __pass_object_size0 buf,
+ size_t count, off64_t offset) __overloadable {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -413,7 +413,7 @@
__error_if_overflows_objectsize(count, __bos0(buf));
__BIONIC_FORTIFY_INLINE
-ssize_t read(int fd, void* const __pass_object_size buf, size_t count)
+ssize_t read(int fd, void* const __pass_object_size0 buf, size_t count)
__overloadable {
size_t bos = __bos0(buf);
@@ -434,7 +434,7 @@
__error_if_overflows_objectsize(count, __bos0(buf));
__BIONIC_FORTIFY_INLINE
-ssize_t write(int fd, const void* const __pass_object_size buf, size_t count)
+ssize_t write(int fd, const void* const __pass_object_size0 buf, size_t count)
__overloadable {
size_t bos = __bos0(buf);