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/stdio.h b/libc/include/stdio.h
index 6a76da6..f1f86a3 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -341,7 +341,7 @@
__errorattr("size * count is too large");
__BIONIC_FORTIFY_INLINE
-size_t fread(void *__restrict const __pass_object_size buf, size_t size,
+size_t fread(void *__restrict const __pass_object_size0 buf, size_t size,
size_t count, FILE *__restrict stream) __overloadable {
size_t bos = __bos0(buf);
@@ -366,8 +366,9 @@
__errorattr("size * count is too large");
__BIONIC_FORTIFY_INLINE
-size_t fwrite(const void * __restrict const __pass_object_size buf, size_t size,
- size_t count, FILE * __restrict stream) __overloadable {
+size_t fwrite(const void * __restrict const __pass_object_size0 buf,
+ size_t size, size_t count, FILE * __restrict stream)
+ __overloadable {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {