From 5641c23fa770b56b7f0f2e79df22cd6bbb8c4972 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 27 Jun 2018 15:28:09 +0000 Subject: [PATCH] audit(4): fix Coverity issues Fix several incorrect buffer size arguments and a file descriptor leak. Submitted by: aniketp Reported by: Coverity CID: 1393489 1393501 1393509 1393510 1393514 1393515 1393516 CID: 1393517 1393518 1393519 MFC after: 2 weeks X-MFC-With: 335284 X-MFC-With: 335318 X-MFC-With: 335320 Sponsored by: Google, Inc. (GSoC 2018) Differential Revision: https://reviews.freebsd.org/D16000 --- tests/sys/audit/administrative.c | 2 +- tests/sys/audit/file-attribute-access.c | 2 +- tests/sys/audit/file-attribute-modify.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/sys/audit/administrative.c b/tests/sys/audit/administrative.c index 5a8a8ac5ef5..5511ddf8ac9 100644 --- a/tests/sys/audit/administrative.c +++ b/tests/sys/audit/administrative.c @@ -163,7 +163,7 @@ ATF_TC_BODY(nfs_getfh_success, tc) snprintf(adregex, sizeof(adregex), "nfs_getfh.*%d.*ret.*success", pid); /* File needs to exist to call getfh(2) */ - ATF_REQUIRE(filedesc = open(path, O_CREAT, mode) != -1); + ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1); FILE *pipefd = setup(fds, auclass); ATF_REQUIRE_EQ(0, getfh(path, &fhp)); check_audit(fds, adregex, pipefd); diff --git a/tests/sys/audit/file-attribute-access.c b/tests/sys/audit/file-attribute-access.c index 8d93e5a3fb9..f71bd5f7a36 100644 --- a/tests/sys/audit/file-attribute-access.c +++ b/tests/sys/audit/file-attribute-access.c @@ -44,9 +44,9 @@ static pid_t pid; static fhandle_t fht; static int filedesc, fhdesc; static char extregex[80]; +static char buff[] = "ezio"; static struct stat statbuff; static struct statfs statfsbuff; -static const char *buff = "ezio"; static const char *auclass = "fa"; static const char *name = "authorname"; static const char *path = "fileforaudit"; diff --git a/tests/sys/audit/file-attribute-modify.c b/tests/sys/audit/file-attribute-modify.c index bdcaa639dba..d52e67529fb 100644 --- a/tests/sys/audit/file-attribute-modify.c +++ b/tests/sys/audit/file-attribute-modify.c @@ -46,7 +46,7 @@ static int filedesc, retval; static struct pollfd fds[1]; static mode_t mode = 0777; static char extregex[80]; -static const char *buff = "ezio"; +static char buff[] = "ezio"; static const char *auclass = "fm"; static const char *name = "authorname"; static const char *path = "fileforaudit"; -- 2.45.2