git: 95a52eb29ca9 - stable/13 - diff: Don't treat null characters like carriage returns in readhash().

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 24 Jan 2023 05:43:15 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=95a52eb29ca93fb457ac618b8de7a754700e55c4

commit 95a52eb29ca93fb457ac618b8de7a754700e55c4
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-11-16 03:16:50 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-01-24 05:12:00 +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
    
    (cherry picked from commit 4e0771714d6192119dcf7553b921bf88866d8925)
---
 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 72a4d5f25b07..94998a364715 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1376,6 +1376,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);
@@ -1394,6 +1395,7 @@ readhash(FILE *f, int flags, unsigned *hash)
 			}
 			/* FALLTHROUGH */
 		default:
+		hashchar:
 			if (space && (flags & D_IGNOREBLANKS) == 0) {
 				i++;
 				space = 0;