Added regression tests for recent bug fix involving accept(), recvfrom() and
getsockopt() being allowed to received a NULL buffer.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1581 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am
index 4ebbf1c..dfd9f8a 100644
--- a/memcheck/tests/Makefile.am
+++ b/memcheck/tests/Makefile.am
@@ -45,6 +45,7 @@
nanoleak.stderr.exp nanoleak.vgtest \
nanoleak_supp.stderr.exp nanoleak_supp.vgtest nanoleak.supp \
new_override.stderr.exp new_override.vgtest \
+ null_socket.stderr.exp null_socket.vgtest \
overlap.stderr.exp overlap.stdout.exp overlap.vgtest
pushfpopf.stderr.exp pushfpopf.stdout.exp pushfpopf.vgtest \
realloc1.stderr.exp realloc1.vgtest \
@@ -64,7 +65,8 @@
badaddrvalue badfree badjump badloop buflen_check clientperm \
doublefree error_counts errs1 exitprog fprw fwrite inits inline \
malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
- memalign_test memcmptest mmaptest nanoleak overlap pushfpopf \
+ memalign_test memcmptest mmaptest nanoleak null_socket \
+ overlap pushfpopf \
realloc1 realloc2 sigaltstack signal2 supp1 supp2 suppfree \
trivialleak tronical weirdioctl \
mismatches new_override
@@ -98,6 +100,7 @@
memalign_test_SOURCES = memalign_test.c
memcmptest_SOURCES = memcmptest.c
nanoleak_SOURCES = nanoleak.c
+null_socket_SOURCES = null_socket.c
overlap_SOURCES = overlap.c
pushfpopf_SOURCES = pushfpopf_c.c pushfpopf_s.s
realloc1_SOURCES = realloc1.c
diff --git a/memcheck/tests/null_socket.c b/memcheck/tests/null_socket.c
new file mode 100644
index 0000000..a2e203e
--- /dev/null
+++ b/memcheck/tests/null_socket.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+
+// It's legit to have NULL buffers; before the bug was fixed Valgrind
+// reported spurious errors for the buffers.
+int main(void)
+{
+ if (-1 != accept(99, NULL, 0))
+ printf("accept succeeded?\n");
+
+ if (-1 != recvfrom(0, NULL, 0, 0, NULL, 0))
+ printf("recvfrom succeeded?\n");
+
+ if (-1 != getsockopt(0, 0, 0, NULL, 0))
+ printf("getsockopt succeeded?\n");
+
+ return 0;
+}
diff --git a/memcheck/tests/null_socket.stderr.exp b/memcheck/tests/null_socket.stderr.exp
new file mode 100644
index 0000000..c4aa6f0
--- /dev/null
+++ b/memcheck/tests/null_socket.stderr.exp
@@ -0,0 +1,7 @@
+
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
+For a detailed leak analysis, rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
diff --git a/memcheck/tests/null_socket.vgtest b/memcheck/tests/null_socket.vgtest
new file mode 100644
index 0000000..7dc33a9
--- /dev/null
+++ b/memcheck/tests/null_socket.vgtest
@@ -0,0 +1 @@
+prog: null_socket