diff --git a/src/digest.c b/src/digest.c index 9ee37a104..9398a133e 100644 --- a/src/digest.c +++ b/src/digest.c @@ -1073,6 +1073,11 @@ digest_check (char const *checkfile_name) line_length -= line[line_length - 1] == '\n'; /* Remove any trailing carriage return. */ line_length -= line[line_length - (0 < line_length)] == '\r'; + + /* Ignore empty lines. */ + if (line_length == 0) + continue; + line[line_length] = '\0'; if (! (split_3 (line, line_length, &hex_digest, &binary, &filename) diff --git a/tests/misc/md5sum.pl b/tests/misc/md5sum.pl index 09c2174f5..64b67deb3 100755 --- a/tests/misc/md5sum.pl +++ b/tests/misc/md5sum.pl @@ -53,18 +53,15 @@ my @Tests = {IN=> {'f.md5' => "$degenerate f\r\n"}}, {OUT=>"f: OK\n"}], - # Same as above, but with an added empty line, to provoke --strict. + # Same as above, but with an added empty line, to test --strict. ['ck-strict-1', '--check --strict', {AUX=> {f=> ''}}, {IN=> {'f.md5' => "$degenerate f\n\n"}}, - {OUT=>"f: OK\n"}, - {ERR=>"md5sum: " - . "WARNING: 1 line is improperly formatted\n"}, - {EXIT=> 1}], + {OUT=>"f: OK\n"}], # As above, but with the invalid line first, to ensure that following # lines are processed in spite of the preceding invalid input line. ['ck-strict-2', '--check --strict', {AUX=> {f=> ''}}, - {IN=> {'in.md5' => "\n$degenerate f\n"}}, + {IN=> {'in.md5' => "ERR\n$degenerate f\n"}}, {OUT=>"f: OK\n"}, {ERR=>"md5sum: " . "WARNING: 1 line is improperly formatted\n"},