Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jan 2016 21:59:18 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r294103 - head/tools/regression/sockets/accf_data_attach
Message-ID:  <201601152159.u0FLxIdA090329@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Fri Jan 15 21:59:18 2016
New Revision: 294103
URL: https://svnweb.freebsd.org/changeset/base/294103

Log:
  - Check for accf_filter before running the tests, otherwise it will always
    fail at subtest 9/11
  - Use strncpy instead of strcpy with afa.af_name

Modified:
  head/tools/regression/sockets/accf_data_attach/accf_data_attach.c

Modified: head/tools/regression/sockets/accf_data_attach/accf_data_attach.c
==============================================================================
--- head/tools/regression/sockets/accf_data_attach/accf_data_attach.c	Fri Jan 15 21:45:53 2016	(r294102)
+++ head/tools/regression/sockets/accf_data_attach/accf_data_attach.c	Fri Jan 15 21:59:18 2016	(r294103)
@@ -27,6 +27,7 @@
  */
 
 #include <sys/types.h>
+#include <sys/module.h>
 #include <sys/socket.h>
 
 #include <netinet/in.h>
@@ -65,6 +66,16 @@ main(void)
 	socklen_t len;
 	int lso, ret;
 
+	/* XXX: PLAIN_TEST_REQUIRE_MODULE "backport" for stable/9 */
+	const char *_mod_name = "accf_data";
+
+	if (modfind(_mod_name) == -1) {
+		printf("1..0 # SKIP - module %s could not be resolved: %s\n",
+		    _mod_name, strerror(errno));
+		_exit(0);
+	}
+	/* XXX: PLAIN_TEST_REQUIRE_MODULE for stable/9 */
+
 	printf("1..11\n");
 
 	/*
@@ -119,7 +130,7 @@ main(void)
 	 * yet a listen() socket.
 	 */
 	bzero(&afa, sizeof(afa));
-	strcpy(afa.af_name, ACCF_NAME);
+	strncpy(afa.af_name, ACCF_NAME, sizeof(afa.af_name));
 	ret = setsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa));
 	if (ret == 0)
 		errx(-1, "not ok 5 - setsockopt() before listen() succeeded");
@@ -164,7 +175,7 @@ main(void)
 	 * Step 8: After listen().  This call to setsockopt() should succeed.
 	 */
 	bzero(&afa, sizeof(afa));
-	strcpy(afa.af_name, ACCF_NAME);
+	strncpy(afa.af_name, ACCF_NAME, sizeof(afa.af_name));
 	ret = setsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa));
 	if (ret != 0)
 		errx(-1, "not ok 9 - setsockopt() after listen() failed with %d "



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601152159.u0FLxIdA090329>