diff options
author | ngie <ngie@FreeBSD.org> | 2016-04-20 20:48:54 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2016-04-20 20:48:54 +0000 |
commit | 5f2b047022be2956b9039b831af165302541106b (patch) | |
tree | 2ef1ad879b6a941d751793236a922f2af7f2bea6 /contrib/netbsd-tests/lib/libc | |
parent | 2253af0f89b21c7e68ceda1a83902e47b11b0c39 (diff) | |
download | FreeBSD-src-5f2b047022be2956b9039b831af165302541106b.zip FreeBSD-src-5f2b047022be2956b9039b831af165302541106b.tar.gz |
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"
Diffstat (limited to 'contrib/netbsd-tests/lib/libc')
-rw-r--r-- | contrib/netbsd-tests/lib/libc/ssp/h_read.c | 4 |
1 files changed, 3 insertions, 1 deletions
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 <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); |