svn commit: r319063 - head/tests/sys/kern

Ngie Cooper ngie at FreeBSD.org
Sun May 28 09:21:30 UTC 2017


Author: ngie
Date: Sun May 28 09:21:28 2017
New Revision: 319063
URL: https://svnweb.freebsd.org/changeset/base/319063

Log:
  Send all of `data`, not just a portion of it
  
  It was sending only a long's worth (4 or 8 bytes) of data previously
  (instead of the entire buffer) via send(2).
  
  MFC after:	1 week
  Reported by:	Coverity
  CID:		1229966, 1229967, 1230004, 1230005
  Sponsored by:	Dell EMC Isilon

Modified:
  head/tests/sys/kern/unix_seqpacket_test.c

Modified: head/tests/sys/kern/unix_seqpacket_test.c
==============================================================================
--- head/tests/sys/kern/unix_seqpacket_test.c	Sun May 28 09:08:30 2017	(r319062)
+++ head/tests/sys/kern/unix_seqpacket_test.c	Sun May 28 09:21:28 2017	(r319063)
@@ -762,7 +762,7 @@ ATF_TC_BODY(shutdown_send, tc)
 	/* ATF's isolation mechanisms will guarantee uniqueness of this file */
 	const char *path = "sock";
 	const char *data = "data";
-	ssize_t ssize;
+	ssize_t datalen, ssize;
 	int s, err, s2;
 
 	s = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
@@ -786,8 +786,9 @@ ATF_TC_BODY(shutdown_send, tc)
 	}
 
 	ATF_CHECK_EQ(0, shutdown(s2, SHUT_RDWR));
+	datalen = strlen(data) + 1;	/* +1 for the null */
 	/* USE MSG_NOSIGNAL so we don't get SIGPIPE */
-	ssize = send(s2, data, sizeof(data), MSG_EOR | MSG_NOSIGNAL);
+	ssize = send(s2, data, datalen, MSG_EOR | MSG_NOSIGNAL);
 	ATF_CHECK_EQ(EPIPE, errno);
 	ATF_CHECK_EQ(-1, ssize);
 	close(s);
@@ -802,6 +803,7 @@ ATF_TC_BODY(shutdown_send_sigpipe, tc)
 	/* ATF's isolation mechanisms will guarantee uniqueness of this file */
 	const char *path = "sock";
 	const char *data = "data";
+	ssize_t datalen;
 	int s, err, s2;
 
 	s = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
@@ -826,7 +828,8 @@ ATF_TC_BODY(shutdown_send_sigpipe, tc)
 
 	ATF_CHECK_EQ(0, shutdown(s2, SHUT_RDWR));
 	ATF_REQUIRE(SIG_ERR != signal(SIGPIPE, shutdown_send_sigpipe_handler));
-	(void)send(s2, data, sizeof(data), MSG_EOR);
+	datalen = strlen(data) + 1;	/* +1 for the null */
+	(void)send(s2, data, sizeof(*data), MSG_EOR);
 	ATF_CHECK_EQ(1, got_sigpipe);
 	close(s);
 	close(s2);


More information about the svn-src-all mailing list