From 364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 7 Dec 2006 00:25:48 +0100 Subject: Imported from util-linux-2.11f tarball. --- text-utils/more.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'text-utils/more.c') diff --git a/text-utils/more.c b/text-utils/more.c index ac62d070c..0411b17fe 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -529,7 +529,7 @@ checkf (fs, clearfirst) if (magic(f, fs)) return((FILE *)NULL); c = Getc(f); - *clearfirst = c == '\f'; + *clearfirst = (c == '\f'); Ungetc (c, f); if ((file_size = stbuf.st_size) == 0) file_size = LONG_MAX; @@ -548,6 +548,10 @@ magic(f, fs) { char twobytes[2]; + /* don't try to look ahead if the input is unseekable */ + if (fseek(f, 0L, SEEK_SET)) + return(0); + if (fread(twobytes, 2, 1, f) == 1) { switch(twobytes[0] + (twobytes[1]<<8)) { case OMAGIC: /* 0407 */ -- cgit v1.2.3-55-g7522