Add GNU-compatible strerror_r.
We already had the POSIX strerror_r, but some third-party code defines _GNU_SOURCE and expects to get the GNU strerror_r instead. This exposed a bug in the libc internal logging functions where unlike their standard brethren they wouldn't return the number of bytes they'd have liked to have written. Bug: 16243479 Change-Id: I1745752ccbdc569646d34f5071f6df2be066d5f4
This commit is contained in:
@@ -176,3 +176,15 @@ TEST(libc_logging, lld_LLONG_MIN) {
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(libc_logging, buffer_overrun) {
|
||||
#if defined(__BIONIC__)
|
||||
char buf[BUFSIZ];
|
||||
ASSERT_EQ(11, __libc_format_buffer(buf, sizeof(buf), "hello %s", "world"));
|
||||
EXPECT_STREQ("hello world", buf);
|
||||
ASSERT_EQ(11, __libc_format_buffer(buf, 8, "hello %s", "world"));
|
||||
EXPECT_STREQ("hello w", buf);
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
Reference in New Issue
Block a user