From owner-svn-src-all@freebsd.org Fri Feb 10 03:22:01 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F12A3CD977F; Fri, 10 Feb 2017 03:22:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BAA58DF2; Fri, 10 Feb 2017 03:22:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1A3M0jk023506; Fri, 10 Feb 2017 03:22:00 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1A3M0hu023505; Fri, 10 Feb 2017 03:22:00 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201702100322.v1A3M0hu023505@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 10 Feb 2017 03:22:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r313520 - stable/10/contrib/netbsd-tests/fs/tmpfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Feb 2017 03:22:02 -0000 Author: ngie Date: Fri Feb 10 03:22:00 2017 New Revision: 313520 URL: https://svnweb.freebsd.org/changeset/base/313520 Log: MFC r311233,r311377: r311233: Fix Coverity issues - Initialize .sun_len before passing it to strlcpy and bind. - Close fd on error CID: 978283, 979581 r311377: Redo fix for CID 979581 The previous change was flawed in terms of how it calculated the buffer length for the sockaddr_un object. Use SUN_LEN where appropriate and mute the Coverity complaint by using memset(.., 0, ..) to zero out the entire structure instead of setting .sun_len to a bogus value and strlcpy'ing in the contents of argv[1]. SUN_LEN is now being passed to bind(2) as well. For some odd reason this wasn't flagged as a bug with Coverity. Modified: stable/10/contrib/netbsd-tests/fs/tmpfs/h_tools.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/netbsd-tests/fs/tmpfs/h_tools.c ============================================================================== --- stable/10/contrib/netbsd-tests/fs/tmpfs/h_tools.c Fri Feb 10 03:17:11 2017 (r313519) +++ stable/10/contrib/netbsd-tests/fs/tmpfs/h_tools.c Fri Feb 10 03:22:00 2017 (r313520) @@ -243,12 +243,21 @@ sockets_main(int argc, char **argv) return EXIT_FAILURE; } +#ifdef __FreeBSD__ + memset(&addr, 0, sizeof(addr)); +#endif (void)strlcpy(addr.sun_path, argv[1], sizeof(addr.sun_path)); addr.sun_family = PF_UNIX; - +#ifdef __FreeBSD__ + error = bind(fd, (struct sockaddr *)&addr, SUN_LEN(&addr)); +#else error = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); +#endif if (error == -1) { warn("connect"); +#ifdef __FreeBSD__ + (void)close(fd); +#endif return EXIT_FAILURE; }