libc fortify: error on realpath(NULL, foo)
I've half a mind to make this a warning instead, since this sort of
call isn't UB. That said:
- if the user really wants this (I can't imagine why they would), they
can just put NULL in a non-const variable,
- we're slowly moving to -Werror ~everywhere anyway, and
- it's presumably easier to change this from an error to a warning than
the other way around
Bug: 12231437
Test: m checkbuild on bullhead internal master. No new
CtsBionicTestCases failures.
Change-Id: Ie8bf5a3455f663686fda4a7450fb35d147fa745e
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index c724f74..7d2dc20 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -184,7 +184,9 @@
TEST(stdlib, realpath__NULL_filename) {
errno = 0;
- char* p = realpath(NULL, NULL);
+ // Work around the compile-time error generated by FORTIFY here.
+ const char* path = NULL;
+ char* p = realpath(path, NULL);
ASSERT_TRUE(p == NULL);
ASSERT_EQ(EINVAL, errno);
}