libc: fortify recvfrom()
Fortify calls to recv() and recvfrom().
We use __bos0 to match glibc's behavior, and because I haven't
tested using __bos.
Change-Id: Iad6ae96551a89af17a9c347b80cdefcf2020c505
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index 5ec15b8..4ea868b 100644
--- a/tests/fortify_test.cpp
+++ b/tests/fortify_test.cpp
@@ -19,6 +19,7 @@
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/socket.h>
// We have to say "DeathTest" here so gtest knows to run this test (which exits)
// in its own process. Unfortunately, the C preprocessor doesn't give us an
@@ -525,6 +526,13 @@
ASSERT_EXIT(umask(mask), testing::KilledBySignal(SIGABRT), "");
}
+TEST(DEATHTEST, recv_fortified) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ size_t data_len = atoi("11"); // suppress compiler optimizations
+ char buf[10];
+ ASSERT_EXIT(recv(0, buf, data_len, 0), testing::KilledBySignal(SIGABRT), "");
+}
+
extern "C" char* __strncat_chk(char*, const char*, size_t, size_t);
extern "C" char* __strcat_chk(char*, const char*, size_t);