From owner-svn-src-stable-10@freebsd.org Fri Apr 8 20:43:51 2016 Return-Path: Delivered-To: svn-src-stable-10@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 D382AB09ECD; Fri, 8 Apr 2016 20:43:51 +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 mx1.freebsd.org (Postfix) with ESMTPS id 8BC7D1168; Fri, 8 Apr 2016 20:43:51 +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 u38KhoBc062604; Fri, 8 Apr 2016 20:43:50 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u38Khori062603; Fri, 8 Apr 2016 20:43:50 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201604082043.u38Khori062603@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 8 Apr 2016 20:43:50 +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: r297723 - stable/10/sbin/devd/tests X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2016 20:43:51 -0000 Author: asomers Date: Fri Apr 8 20:43:50 2016 New Revision: 297723 URL: https://svnweb.freebsd.org/changeset/base/297723 Log: MFC 270231 Misc fixes suggested by Coverity. sbin/devd/tests/client_test.c * In the event that popen fails, don't dereference its return value. * Fix array overwrite in the stream and seqpacket tests. * Close sockets at the end of successful ATF tests. Modified: stable/10/sbin/devd/tests/client_test.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/devd/tests/client_test.c ============================================================================== --- stable/10/sbin/devd/tests/client_test.c Fri Apr 8 18:15:31 2016 (r297722) +++ stable/10/sbin/devd/tests/client_test.c Fri Apr 8 20:43:50 2016 (r297723) @@ -58,6 +58,7 @@ create_two_events(void) snprintf(destroy_cmd, nitems(destroy_cmd), "mdconfig -d -u %s", mdname); destroy_stdout = popen(destroy_cmd, "r"); + ATF_REQUIRE(destroy_stdout != NULL); /* We expect no output */ ATF_REQUIRE_EQ(0, pclose(destroy_stdout)); } @@ -105,7 +106,8 @@ ATF_TC_BODY(seqpacket, tc) ssize_t len; char event[1024]; - len = recv(s, event, sizeof(event), MSG_WAITALL); + /* Read 1 less than sizeof(event) to allow space for NULL */ + len = recv(s, event, sizeof(event) - 1, MSG_WAITALL); ATF_REQUIRE(len != -1); /* NULL terminate the result */ event[len] = '\0'; @@ -118,6 +120,8 @@ ATF_TC_BODY(seqpacket, tc) if (cmp == 0) got_destroy_event = true; } + + close(s); } /* @@ -160,7 +164,8 @@ ATF_TC_BODY(stream, tc) ssize_t newlen; char *create_pos, *destroy_pos; - newlen = read(s, &event[len], sizeof(event) - len); + /* Read 1 less than sizeof(event) to allow space for NULL */ + newlen = read(s, &event[len], sizeof(event) - len - 1); ATF_REQUIRE(newlen != -1); len += newlen; /* NULL terminate the result */ @@ -174,8 +179,9 @@ ATF_TC_BODY(stream, tc) destroy_pos = strstr(event, destroy_pat); if (destroy_pos != NULL) got_destroy_event = true; - } + + close(s); } /*