Module Name: src
Committed By: christos
Date: Mon Jan 16 16:35:57 UTC 2017
Modified Files:
src/tests/lib/libc/ssp: h_read.c
Log Message:
PR/51894: Ngie Cooper: Use /dev/zero to read instead of stdin
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/ssp/h_read.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libc/ssp/h_read.c
diff -u src/tests/lib/libc/ssp/h_read.c:1.1 src/tests/lib/libc/ssp/h_read.c:1.2
--- src/tests/lib/libc/ssp/h_read.c:1.1 Sun Dec 26 21:04:19 2010
+++ src/tests/lib/libc/ssp/h_read.c Mon Jan 16 11:35:57 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+/* $NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,9 +29,11 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+__RCSID("$NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 christos Exp $");
#include <sys/param.h>
+#include <fcntl.h>
+#include <paths.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -40,8 +42,13 @@ int
main(int argc, char *argv[])
{
char b[MAXPATHLEN];
+ int fd, n;
size_t len = atoi(argv[1]);
- (void)read(0, b, len);
+
+ if ((fd = open(_PATH_DEVZERO, O_RDONLY)) == -1)
+ abort();
+ if ((n = read(fd, b, len)) == -1)
+ abort();
(void)printf("%s\n", b);
- return 0;
+ return (0);
}