From owner-svn-src-head@freebsd.org Tue Feb 13 19:17:33 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE1B1F1C09F; Tue, 13 Feb 2018 19:17:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7EF0F6B1EA; Tue, 13 Feb 2018 19:17:33 +0000 (UTC) (envelope-from asomers@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7883B24F04; Tue, 13 Feb 2018 19:17:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1DJHXft047412; Tue, 13 Feb 2018 19:17:33 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1DJHXfY047411; Tue, 13 Feb 2018 19:17:33 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201802131917.w1DJHXfY047411@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 13 Feb 2018 19:17:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329236 - head/contrib/netbsd-tests/kernel X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/contrib/netbsd-tests/kernel X-SVN-Commit-Revision: 329236 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Feb 2018 19:17:34 -0000 Author: asomers Date: Tue Feb 13 19:17:33 2018 New Revision: 329236 URL: https://svnweb.freebsd.org/changeset/base/329236 Log: Fix Coverity CIDs in the sys/kern/sysv_test tests CID 979810: strcpy => strlcpy CID 1193367: don't leak a file descriptor CID 1299856: Check the return value of read(2) Reported by: Coverity Coverity CID: 978910 1193367 1299856 MFC after: 3 weeks X-MFC-With: 328896 Sponsored by: Spectra Logic Corp Modified: head/contrib/netbsd-tests/kernel/t_sysv.c Modified: head/contrib/netbsd-tests/kernel/t_sysv.c ============================================================================== --- head/contrib/netbsd-tests/kernel/t_sysv.c Tue Feb 13 17:58:02 2018 (r329235) +++ head/contrib/netbsd-tests/kernel/t_sysv.c Tue Feb 13 19:17:33 2018 (r329236) @@ -129,7 +129,8 @@ read_int(const char *path) return -1; else { int value; - read(input, &value, sizeof(value)); + ATF_REQUIRE_EQ(read(input, &value, sizeof(value)), sizeof(value)); + close(input); return value; } } @@ -284,7 +285,7 @@ ATF_TC_BODY(msg, tc) * Send the first message to the receiver and wait for the ACK. */ m.mtype = MTYPE_1; - strcpy(m.mtext, m1_str); + strlcpy(m.mtext, m1_str, sizeof(m.mtext)); ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, MESSAGE_TEXT_LEN, 0) != -1, "sender: msgsnd 1: %d", errno); @@ -298,7 +299,7 @@ ATF_TC_BODY(msg, tc) * Send the second message to the receiver and wait for the ACK. */ m.mtype = MTYPE_2; - strcpy(m.mtext, m2_str); + strlcpy(m.mtext, m2_str, sizeof(m.mtext)); ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, MESSAGE_TEXT_LEN, 0) != -1, "sender: msgsnd 2: %d", errno);