Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jan 2017 02:46:36 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r311233 - head/contrib/netbsd-tests/fs/tmpfs
Message-ID:  <201701040246.v042kaEh039041@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Wed Jan  4 02:46:36 2017
New Revision: 311233
URL: https://svnweb.freebsd.org/changeset/base/311233

Log:
  Fix Coverity issues
  
  - Initialize .sun_len before passing it to strlcpy and bind.
  - Close fd on error
  
  MFC after:	3 days
  Reported by:	Coverity
  CID:		978283, 979581

Modified:
  head/contrib/netbsd-tests/fs/tmpfs/h_tools.c

Modified: head/contrib/netbsd-tests/fs/tmpfs/h_tools.c
==============================================================================
--- head/contrib/netbsd-tests/fs/tmpfs/h_tools.c	Wed Jan  4 02:43:33 2017	(r311232)
+++ head/contrib/netbsd-tests/fs/tmpfs/h_tools.c	Wed Jan  4 02:46:36 2017	(r311233)
@@ -243,12 +243,19 @@ sockets_main(int argc, char **argv)
 		return EXIT_FAILURE;
 	}
 
+#ifdef	__FreeBSD__
+	addr.sun_len = sizeof(addr.sun_path);
+	(void)strlcpy(addr.sun_path, argv[1], addr.sun_len);
+#else
 	(void)strlcpy(addr.sun_path, argv[1], sizeof(addr.sun_path));
+#endif
 	addr.sun_family = PF_UNIX;
-
 	error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
 	if (error == -1) {
 		warn("connect");
+#ifdef	__FreeBSD__
+		(void)close(fd);
+#endif
 		return EXIT_FAILURE;
 	}
 



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