git: 4e0771714d61 - main - diff: Don't treat null characters like carriage returns in readhash().
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 16 Nov 2022 03:23:10 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4e0771714d6192119dcf7553b921bf88866d8925 commit 4e0771714d6192119dcf7553b921bf88866d8925 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-11-16 03:16:50 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-11-16 03:16:50 +0000 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: 3cbf98e2bee9 diff: read whole files to determine if they are ASCII text Differential Revision: https://reviews.freebsd.org/D36813 --- usr.bin/diff/diffreg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index c9111fe7eaee..b5e1f23b2d00 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -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;