aboutsummaryrefslogtreecommitdiffstats
path: root/tests/fortify_test.cpp
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2013-09-24 16:32:07 -0700
committerNick Kralevich <nnk@google.com>2013-09-24 16:45:01 -0700
commit60f4f9a5b99a0a66817f50edfc2194a49f8b5146 (patch)
tree13900546cac13512fd4dfd37d3f9e98606c750d2 /tests/fortify_test.cpp
parent759111cadf84f337f98177259d9e3f9d39c9eea9 (diff)
downloadandroid_bionic-60f4f9a5b99a0a66817f50edfc2194a49f8b5146.tar.gz
android_bionic-60f4f9a5b99a0a66817f50edfc2194a49f8b5146.tar.bz2
android_bionic-60f4f9a5b99a0a66817f50edfc2194a49f8b5146.zip
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
Diffstat (limited to 'tests/fortify_test.cpp')
-rw-r--r--tests/fortify_test.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index 5ec15b811..4ea868b79 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 @@ TEST(DEATHTEST, umask_fortified) {
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);