diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2010-10-12 17:23:22 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2010-10-12 17:23:22 +0000 |
commit | caebab4963480a26b31eae028efc040871c99305 (patch) | |
tree | f1ef489f3a8c874765d8c6e3c58f37a2e1524b98 /usr.bin/hexdump/display.c | |
parent | 27f134ab20d82f966e3a59953db8729e4dc9d3bb (diff) |
If the input length was specified, use it to set the stdio buffer
size for fread(). Otherwise, stdio will read as much as it can
(using a very large buffer) which may cause a hang if the input
comes from a blocking device such as /dev/srandom. OK deraadt@
Diffstat (limited to 'usr.bin/hexdump/display.c')
-rw-r--r-- | usr.bin/hexdump/display.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index 75136f1185c..74b72e81503 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.18 2009/10/27 23:59:39 deraadt Exp $ */ +/* $OpenBSD: display.c,v 1.19 2010/10/12 17:23:21 millert Exp $ */ /* $NetBSD: display.c,v 1.12 2001/12/07 15:14:29 bjh21 Exp $ */ /* @@ -310,8 +310,11 @@ next(char **argv) doskip(statok ? *_argv : "stdin", statok); if (*_argv) ++_argv; - if (!skip) + if (!skip) { + if (iobuf != NULL) + setvbuf(stdin, iobuf, _IOFBF, iobufsiz); return(1); + } } /* NOTREACHED */ } |