From 5f2b047022be2956b9039b831af165302541106b Mon Sep 17 00:00:00 2001 From: ngie Date: Wed, 20 Apr 2016 20:48:54 +0000 Subject: 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" --- contrib/netbsd-tests/lib/libc/ssp/h_read.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'contrib/netbsd-tests/lib/libc') diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_read.c b/contrib/netbsd-tests/lib/libc/ssp/h_read.c index 1197b6c..ac0aad4 100644 --- a/contrib/netbsd-tests/lib/libc/ssp/h_read.c +++ b/contrib/netbsd-tests/lib/libc/ssp/h_read.c @@ -38,6 +38,7 @@ __RCSID("$NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $"); #ifdef __FreeBSD__ #include +#include 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); -- cgit v1.1