Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 May 2016 05:20:34 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300649 - head/bin/setfacl
Message-ID:  <201605250520.u4P5KY9e087035@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Wed May 25 05:20:34 2016
New Revision: 300649
URL: https://svnweb.freebsd.org/changeset/base/300649

Log:
  Fix Coverity CID 1019054 (String not null terminated) in setfacl.
  
  Increase the size of buf[] by one to allow room for a NUL character
  at the end.
  
  Reported by:	Coverity
  CID:		1019054
  MFC after:	1 week

Modified:
  head/bin/setfacl/file.c

Modified: head/bin/setfacl/file.c
==============================================================================
--- head/bin/setfacl/file.c	Wed May 25 05:12:56 2016	(r300648)
+++ head/bin/setfacl/file.c	Wed May 25 05:20:34 2016	(r300649)
@@ -43,7 +43,7 @@ acl_t
 get_acl_from_file(const char *filename)
 {
 	FILE *file;
-	char buf[BUFSIZ];
+	char buf[BUFSIZ+1];
 
 	if (filename == NULL)
 		err(1, "(null) filename in get_acl_from_file()");
@@ -61,7 +61,7 @@ get_acl_from_file(const char *filename)
 			err(1, "fopen() %s failed", filename);
 	}
 
-	fread(buf, sizeof(buf), (size_t)1, file);
+	fread(buf, sizeof(buf) - 1, (size_t)1, file);
 	if (ferror(file) != 0) {
 		fclose(file);
 		err(1, "error reading from %s", filename);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605250520.u4P5KY9e087035>