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);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to