diff: Don't treat null characters like carriage returns in readhash().

The implicit fall-through in the !D_FORCEASCII case caused null
characters to be treated as carriage returns honoring the D_STRIPCR,
D_FOLDBLANKS, and D_IGNOREBLANKS flags.

Reported by:	GCC -Wimplicit-fallthrough
Reviewed by:	bapt
Fixes:	 	3cbf98e2be diff: read whole files to determine if they are ASCII text
Differential Revision:	https://reviews.freebsd.org/D36813
This commit is contained in:
John Baldwin 2022-11-15 19:16:50 -08:00
parent 325ba12055
commit 4e0771714d

View File

@ -1338,6 +1338,7 @@ readhash(FILE *f, int flags, unsigned *hash)
case '\0':
if ((flags & D_FORCEASCII) == 0)
return (RH_BINARY);
goto hashchar;
case '\r':
if (flags & D_STRIPCR) {
t = getc(f);
@ -1356,6 +1357,7 @@ readhash(FILE *f, int flags, unsigned *hash)
}
/* FALLTHROUGH */
default:
hashchar:
if (space && (flags & D_IGNOREBLANKS) == 0) {
i++;
space = 0;