Blob Blame Raw
diff --git a/memcheck/tests/sendmsg.c b/memcheck/tests/sendmsg.c
new file mode 100644
index 0000000..f47da1d
--- /dev/null
+++ b/memcheck/tests/sendmsg.c
@@ -0,0 +1,56 @@
+#include <netinet/ip.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#define PORT 12345
+
+int
+main (int argc, char **argv)
+{
+  int fd;
+  struct sockaddr_in sa;
+  struct msghdr msg;
+  struct iovec iov[2];
+
+  fd = socket (AF_INET, SOCK_DGRAM, 0);
+  if (fd == -1)
+    {
+      perror ("socket()");
+      exit (EXIT_FAILURE);
+    }
+
+  sa.sin_family = AF_INET;
+  sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
+  sa.sin_port = htons (PORT);
+  if (connect (fd, (struct sockaddr *) &sa, sizeof (sa)) == -1)
+    {
+      perror ("connect ()");
+      exit (EXIT_FAILURE);
+    }
+
+  // Create msg_hdr. Note that msg_flags isn't being set.
+  msg.msg_name = NULL;
+  msg.msg_namelen = 0;
+  iov[0].iov_base = "one";
+  iov[0].iov_len = 3;
+  iov[1].iov_base = "two";
+  iov[1].iov_len = 3;
+  msg.msg_iov = &iov;
+  msg.msg_iovlen = 2;
+  msg.msg_control = NULL;
+  msg.msg_controllen = 0;
+
+  ssize_t s = sendmsg (fd, &msg, 0);
+  if (s == -1)
+    {
+      perror ("sendmsg ()");
+      exit (EXIT_FAILURE);
+    }
+  else
+    fprintf (stderr, "sendmsg: %d\n", (int) s);
+
+  exit(0);
+}
diff --git a/memcheck/tests/sendmsg.stderr.exp b/memcheck/tests/sendmsg.stderr.exp
new file mode 100644
index 0000000..1dbac26
--- /dev/null
+++ b/memcheck/tests/sendmsg.stderr.exp
@@ -0,0 +1 @@
+sendmsg: 6
diff --git a/memcheck/tests/sendmsg.vgtest b/memcheck/tests/sendmsg.vgtest
new file mode 100644
index 0000000..f252b62
--- /dev/null
+++ b/memcheck/tests/sendmsg.vgtest
@@ -0,0 +1,2 @@
+prog: sendmsg
+vgopts: -q
-- 
1.7.1

--- valgrind-3.8.1/coregrind/m_syswrap/syswrap-generic.c.orig	2013-02-19 14:45:13.000000000 +0100
+++ valgrind-3.8.1/coregrind/m_syswrap/syswrap-generic.c	2013-02-19 14:48:37.640413500 +0100
@@ -817,7 +817,8 @@
 {
    Char *outmsg = strdupcat ( "di.syswrap.pmrs.1",
                               "sendmsg", msg, VG_AR_CORE );
-   PRE_MEM_READ( outmsg, base, size );
+   if ( read )
+      PRE_MEM_READ( outmsg, base, size );
    VG_(arena_free) ( VG_AR_CORE, outmsg );
 }
 
--- valgrind-3.8.1/memcheck/tests/Makefile.am.orig	2013-02-19 14:45:13.467514264 +0100
+++ valgrind-3.8.1/memcheck/tests/Makefile.am	2013-02-19 14:50:13.871894644 +0100
@@ -179,6 +179,7 @@
 	realloc2.stderr.exp realloc2.vgtest \
 	realloc3.stderr.exp realloc3.vgtest \
 	sbfragment.stdout.exp sbfragment.stderr.exp sbfragment.vgtest \
+	sendmsg.stderr.exp sendmsg.vgtest \
 	sh-mem.stderr.exp sh-mem.vgtest \
 	sh-mem-random.stderr.exp sh-mem-random.stdout.exp64 \
 	sh-mem-random.stdout.exp sh-mem-random.vgtest \
@@ -282,6 +283,7 @@
 	post-syscall \
 	realloc1 realloc2 realloc3 \
 	sbfragment \
+	sendmsg \
 	sh-mem sh-mem-random \
 	sigaltstack signal2 sigprocmask static_malloc sigkill \
 	stpncpy \
--- valgrind-3.8.1/memcheck/tests/Makefile.in.orig	2013-02-19 14:46:14.305186272 +0100
+++ valgrind-3.8.1/memcheck/tests/Makefile.in	2013-02-19 14:59:41.284835217 +0100
@@ -105,20 +105,20 @@
 	partial_load$(EXEEXT) pdb-realloc$(EXEEXT) \
 	pdb-realloc2$(EXEEXT) pipe$(EXEEXT) pointer-trace$(EXEEXT) \
 	post-syscall$(EXEEXT) realloc1$(EXEEXT) realloc2$(EXEEXT) \
-	realloc3$(EXEEXT) sbfragment$(EXEEXT) sh-mem$(EXEEXT) \
-	sh-mem-random$(EXEEXT) sigaltstack$(EXEEXT) signal2$(EXEEXT) \
-	sigprocmask$(EXEEXT) static_malloc$(EXEEXT) sigkill$(EXEEXT) \
-	stpncpy$(EXEEXT) strchr$(EXEEXT) str_tester$(EXEEXT) \
-	supp_unknown$(EXEEXT) supp1$(EXEEXT) supp2$(EXEEXT) \
-	suppfree$(EXEEXT) test-plo$(EXEEXT) trivialleak$(EXEEXT) \
-	unit_libcbase$(EXEEXT) unit_oset$(EXEEXT) varinfo1$(EXEEXT) \
-	varinfo2$(EXEEXT) varinfo3$(EXEEXT) varinfo4$(EXEEXT) \
-	varinfo5$(EXEEXT) varinfo5so.so$(EXEEXT) varinfo6$(EXEEXT) \
-	vcpu_fbench$(EXEEXT) vcpu_fnfns$(EXEEXT) wcs$(EXEEXT) \
-	xml1$(EXEEXT) wrap1$(EXEEXT) wrap2$(EXEEXT) wrap3$(EXEEXT) \
-	wrap4$(EXEEXT) wrap5$(EXEEXT) wrap6$(EXEEXT) wrap7$(EXEEXT) \
-	wrap7so.so$(EXEEXT) wrap8$(EXEEXT) writev1$(EXEEXT) \
-	$(am__EXEEXT_1)
+	realloc3$(EXEEXT) sbfragment$(EXEEXT) sendmsg$(EXEEXT) \
+	sh-mem$(EXEEXT) sh-mem-random$(EXEEXT) sigaltstack$(EXEEXT) \
+	signal2$(EXEEXT) sigprocmask$(EXEEXT) static_malloc$(EXEEXT) \
+	sigkill$(EXEEXT) stpncpy$(EXEEXT) strchr$(EXEEXT) \
+	str_tester$(EXEEXT) supp_unknown$(EXEEXT) supp1$(EXEEXT) \
+	supp2$(EXEEXT) suppfree$(EXEEXT) test-plo$(EXEEXT) \
+	trivialleak$(EXEEXT) unit_libcbase$(EXEEXT) unit_oset$(EXEEXT) \
+	varinfo1$(EXEEXT) varinfo2$(EXEEXT) varinfo3$(EXEEXT) \
+	varinfo4$(EXEEXT) varinfo5$(EXEEXT) varinfo5so.so$(EXEEXT) \
+	varinfo6$(EXEEXT) vcpu_fbench$(EXEEXT) vcpu_fnfns$(EXEEXT) \
+	wcs$(EXEEXT) xml1$(EXEEXT) wrap1$(EXEEXT) wrap2$(EXEEXT) \
+	wrap3$(EXEEXT) wrap4$(EXEEXT) wrap5$(EXEEXT) wrap6$(EXEEXT) \
+	wrap7$(EXEEXT) wrap7so.so$(EXEEXT) wrap8$(EXEEXT) \
+	writev1$(EXEEXT) $(am__EXEEXT_1)
 @DWARF4_TRUE@am__append_12 = dw4
 subdir = memcheck/tests
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -434,6 +434,9 @@
 sbfragment_SOURCES = sbfragment.c
 sbfragment_OBJECTS = sbfragment.$(OBJEXT)
 sbfragment_LDADD = $(LDADD)
+sendmsg_SOURCES = sendmsg.c
+sendmsg_OBJECTS = sendmsg.$(OBJEXT)
+sendmsg_LDADD = $(LDADD)
 sh_mem_SOURCES = sh-mem.c
 sh_mem_OBJECTS = sh-mem.$(OBJEXT)
 sh_mem_LDADD = $(LDADD)
@@ -610,8 +613,8 @@
 	origin3-no.c origin4-many.c origin5-bz2.c origin6-fp.c \
 	overlap.c partial_load.c partiallydefinedeq.c pdb-realloc.c \
 	pdb-realloc2.c pipe.c pointer-trace.c post-syscall.c \
-	realloc1.c realloc2.c realloc3.c sbfragment.c sh-mem.c \
-	sh-mem-random.c sigaltstack.c sigkill.c signal2.c \
+	realloc1.c realloc2.c realloc3.c sbfragment.c sendmsg.c \
+	sh-mem.c sh-mem-random.c sigaltstack.c sigkill.c signal2.c \
 	sigprocmask.c static_malloc.c stpncpy.c str_tester.c strchr.c \
 	$(supp1_SOURCES) $(supp2_SOURCES) $(supp_unknown_SOURCES) \
 	suppfree.c test-plo.c trivialleak.c unit_libcbase.c \
@@ -641,8 +644,8 @@
 	origin3-no.c origin4-many.c origin5-bz2.c origin6-fp.c \
 	overlap.c partial_load.c partiallydefinedeq.c pdb-realloc.c \
 	pdb-realloc2.c pipe.c pointer-trace.c post-syscall.c \
-	realloc1.c realloc2.c realloc3.c sbfragment.c sh-mem.c \
-	sh-mem-random.c sigaltstack.c sigkill.c signal2.c \
+	realloc1.c realloc2.c realloc3.c sbfragment.c sendmsg.c \
+	sh-mem.c sh-mem-random.c sigaltstack.c sigkill.c signal2.c \
 	sigprocmask.c static_malloc.c stpncpy.c str_tester.c strchr.c \
 	$(supp1_SOURCES) $(supp2_SOURCES) $(supp_unknown_SOURCES) \
 	suppfree.c test-plo.c trivialleak.c unit_libcbase.c \
@@ -1112,6 +1115,7 @@
 	realloc2.stderr.exp realloc2.vgtest \
 	realloc3.stderr.exp realloc3.vgtest \
 	sbfragment.stdout.exp sbfragment.stderr.exp sbfragment.vgtest \
+	sendmsg.stderr.exp sendmsg.vgtest \
 	sh-mem.stderr.exp sh-mem.vgtest \
 	sh-mem-random.stderr.exp sh-mem-random.stdout.exp64 \
 	sh-mem-random.stdout.exp sh-mem-random.vgtest \
@@ -1560,6 +1564,9 @@
 sbfragment$(EXEEXT): $(sbfragment_OBJECTS) $(sbfragment_DEPENDENCIES) 
 	@rm -f sbfragment$(EXEEXT)
 	$(LINK) $(sbfragment_OBJECTS) $(sbfragment_LDADD) $(LIBS)
+sendmsg$(EXEEXT): $(sendmsg_OBJECTS) $(sendmsg_DEPENDENCIES) 
+	@rm -f sendmsg$(EXEEXT)
+	$(LINK) $(sendmsg_OBJECTS) $(sendmsg_LDADD) $(LIBS)
 sh-mem$(EXEEXT): $(sh_mem_OBJECTS) $(sh_mem_DEPENDENCIES) 
 	@rm -f sh-mem$(EXEEXT)
 	$(LINK) $(sh_mem_OBJECTS) $(sh_mem_LDADD) $(LIBS)
@@ -1775,6 +1782,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/realloc2.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/realloc3.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sbfragment.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendmsg.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sh-mem-random.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sh-mem.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigaltstack.Po@am__quote@