strings: do not continue if getc or getcharacter returns EOF

Reported by:	cem
This commit is contained in:
Mariusz Zaborski 2019-03-21 05:24:44 +00:00
parent 61d994f1cd
commit 4cb07cba1b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=345361

View File

@ -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;