From 4cb07cba1b0bae396fa3de01a60b152226d0b128 Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski Date: Thu, 21 Mar 2019 05:24:44 +0000 Subject: [PATCH] strings: do not continue if getc or getcharacter returns EOF Reported by: cem --- contrib/elftoolchain/strings/strings.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/elftoolchain/strings/strings.c b/contrib/elftoolchain/strings/strings.c index 233bc851cd4..886c8b48336 100644 --- a/contrib/elftoolchain/strings/strings.c +++ b/contrib/elftoolchain/strings/strings.c @@ -300,7 +300,7 @@ getcharacter(FILE *pfile) for(i = 0; i < encoding_size; i++) { c = getc(pfile); - if (feof(pfile) != 0) + if (c == EOF) return (EOF); buf[i] = c; } @@ -358,7 +358,7 @@ find_strings(const char *name, FILE *pfile, off_t offset, off_t size) memset(obuf, 0, min_len + 1); for(i = 0; i < min_len; i++) { c = getcharacter(pfile); - if (c == EOF && feof(pfile) != 0) + if (c == EOF) goto _exit1; if (PRINTABLE(c)) { obuf[i] = c;