From f5b34e9ff958ae8df8c7e0adfb8dd04ad95d3668 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= Date: Tue, 2 Mar 2010 15:53:31 +0100 Subject: [PATCH] md5sum: handle carriage returns at the eol in input sum files * src/md5sum.c (digest_check): ignore carriage return at the end of line * NEWS: mention that new functionality --- NEWS | 3 +++ src/md5sum.c | 5 +++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/NEWS b/NEWS index 2a3ca63..de85df4 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,9 @@ GNU coreutils NEWS -*- outline -*- using the --with-tty-group[=NAME] option, who also compares the group of the TTY device with NAME (or "tty" if no group name is specified). + md5sum,sha1sum,shaXXXsum utilities no longer fail to handle dos type + end of lines when reading algorithm sums from file (-c/--check option). + ** Changes in behavior ls --color no longer emits the final 3-byte color-resetting escape diff --git a/src/md5sum.c b/src/md5sum.c index edd21ce..31cec3b 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -482,6 +482,11 @@ digest_check (const char *checkfile_name) if (line[line_length - 1] == '\n') line[--line_length] = '\0'; + /* Remove any trailing carriage return. */ + if (line[line_length - 1] == '\r') + line[--line_length] = '\0'; + + if (! (split_3 (line, line_length, &hex_digest, &binary, &filename) && ! (is_stdin && STREQ (filename, "-")) && hex_digits (hex_digest))) -- 1.5.6.1.156.ge903b