From a85752ff4b7c18e6c4cf0c0e43da24080e2d0709 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 18 Apr 2008 23:42:40 +0200 Subject: md5sum -c: ignore a line with a NUL byte among checksum hex digits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/md5sum.c (hex_digits): Require that all "digest_hex_bytes" be hexadecimal digits, not just those before the first NUL byte. This bug dates back to the original version: 3763a4f24eb21be40674d13ff7b04e078f473e85 * tests/misc/md5sum (nul-in-cksum): Test for the above. * NEWS [Bug fixes]: Mention this. Prompted by a report from Flóki Pálsson in http://bugzilla.redhat.com/439531 --- src/md5sum.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/md5sum.c b/src/md5sum.c index ba762d149..f83a7b115 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -343,16 +343,19 @@ split_3 (char *s, size_t s_len, return true; } +/* Return true if S is a NUL-terminated string of DIGEST_HEX_BYTES hex digits. + Otherwise, return false. */ static bool hex_digits (unsigned char const *s) { - while (*s) + unsigned int i; + for (i = 0; i < digest_hex_bytes; i++) { if (!isxdigit (*s)) return false; ++s; } - return true; + return *s == '\0'; } /* An interface to the function, DIGEST_STREAM. -- cgit v1.2.3-70-g09d2