Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Apr 2016 20:48:54 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r298368 - head/contrib/netbsd-tests/lib/libc/ssp
Message-ID:  <201604202048.u3KKmsD0081628@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Wed Apr 20 20:48:54 2016
New Revision: 298368
URL: https://svnweb.freebsd.org/changeset/base/298368

Log:
  Fix coverity issue with contrib/netbsd-tests/lib/libc/ssp/h_read.c
  
  Ensure opening /dev/zero succeeds. Abort the test if it doesn't.
  
  Also, use _PATH_DEVZERO instead of hardcoding "/dev/zero"
  
  MFC after: 2 weeks
  CID: 1251410
  Reported by: Coverity
  Sponsored by: EMC / Isilon Storage Division"

Modified:
  head/contrib/netbsd-tests/lib/libc/ssp/h_read.c

Modified: head/contrib/netbsd-tests/lib/libc/ssp/h_read.c
==============================================================================
--- head/contrib/netbsd-tests/lib/libc/ssp/h_read.c	Wed Apr 20 20:44:30 2016	(r298367)
+++ head/contrib/netbsd-tests/lib/libc/ssp/h_read.c	Wed Apr 20 20:48:54 2016	(r298368)
@@ -38,6 +38,7 @@ __RCSID("$NetBSD: h_read.c,v 1.1 2010/12
 
 #ifdef __FreeBSD__
 #include <fcntl.h>
+#include <paths.h>
 
 int
 main(int argc, char *argv[])
@@ -46,7 +47,8 @@ main(int argc, char *argv[])
 	int fd, n;
 	size_t len = atoi(argv[1]);
 
-	fd = open("/dev/zero", O_RDONLY);
+	if ((fd = open(_PATH_DEVZERO, O_RDONLY)) == -1);
+		abort();
 	if ((n = read(fd, b, len)) == -1)
 		abort();
 	(void)printf("%s\n", b);



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