1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-25 11:37:56 +00:00

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"
This commit is contained in:
Enji Cooper 2016-04-20 20:48:54 +00:00
parent d3591d68a9
commit c935e51525
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298368

View File

@ -38,6 +38,7 @@ __RCSID("$NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
#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);