Date: Sat, 7 Jan 2017 09:30:53 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r311622 - stable/11/contrib/netbsd-tests/fs/tmpfs Message-ID: <201701070930.v079UrmY099668@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Sat Jan 7 09:30:53 2017 New Revision: 311622 URL: https://svnweb.freebsd.org/changeset/base/311622 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/11/contrib/netbsd-tests/fs/tmpfs/h_tools.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/fs/tmpfs/h_tools.c ============================================================================== --- stable/11/contrib/netbsd-tests/fs/tmpfs/h_tools.c Sat Jan 7 09:27:46 2017 (r311621) +++ stable/11/contrib/netbsd-tests/fs/tmpfs/h_tools.c Sat Jan 7 09:30:53 2017 (r311622) @@ -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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701070930.v079UrmY099668>