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
This commit is contained in:
asomers 2018-06-27 15:28:09 +00:00
parent ad717aa158
commit d27905c3a3
3 changed files with 3 additions and 3 deletions

View File

@ -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);

View File

@ -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";

View File

@ -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";