improved fix of checksum line handling #439531 (upstream)

This commit is contained in:
Ondrej Vasik 2008-05-13 13:25:40 +00:00
commit c7e2bdf709
2 changed files with 43 additions and 7 deletions

View file

@ -12,17 +12,30 @@ diff -urNp coreutils-6.10-orig/src/md5sum.c coreutils-6.10/src/md5sum.c
/* Find end of filename. The BSD 'md5' and 'sha1' commands do not escape
diff -urNp coreutils-6.10-orig/src/md5sum.c coreutils-6.10/src/md5sum.c
--- coreutils-6.10-orig/src/md5sum.c 2008-04-18 17:40:03.000000000 +0200
+++ coreutils-6.10/src/md5sum.c 2008-04-18 17:48:05.000000000 +0200
@@ -346,6 +346,8 @@ split_3 (char *s, size_t s_len,
--- coreutils-6.10-orig/src/md5sum.c 2008-05-13 15:09:09.000000000 +0200
+++ coreutils-6.10/src/md5sum.c 2008-05-13 15:10:59.000000000 +0200
@@ -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)
{
+ if (!*s)
+ return false;
while (*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.
diff -urNp coreutils-6.10-orig/tests/misc/sha1sum coreutils-6.10/tests/misc/sha1sum
--- coreutils-6.10-orig/tests/misc/sha1sum 2007-12-13 00:14:28.000000000 +0100
+++ coreutils-6.10/tests/misc/sha1sum 2008-04-15 21:05:43.000000000 +0200
@ -53,3 +66,22 @@ diff -urNp coreutils-6.10-orig/tests/misc/sha1sum coreutils-6.10/tests/misc/sha1
+my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose);
exit $fail;
EOF
diff -urNp coreutils-6.10-orig/tests/misc/md5sum coreutils-6.10/tests/misc/md5sum
--- coreutils-6.10-orig/tests/misc/md5sum 2007-12-13 00:14:28.000000000 +0100
+++ coreutils-6.10/tests/misc/md5sum 2008-05-13 15:15:48.000000000 +0200
@@ -70,6 +70,15 @@ my @Tests =
['check-bsd3', '--check', '--status',
{IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}},
{AUX=> {f=> 'bar'}}, {EXIT=> 1}],
+ ['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1},
+ {ERR=> "md5sum: z: no properly formatted MD5 checksum lines found\n"}],
+ # Ensure that when there's a NUL byte among the checksum hex digits
+ # we detect the invalid formatting and don't even open the file.
+ # Up to coreutils-6.10, this would report:
+ # h: FAILED
+ # md5sum: WARNING: 1 of 1 computed checksum did NOT match
+ ['nul-in-cksum', '--check', {IN=> {'h'=>("\0"x32)." h\n"}}, {EXIT=> 1},
+ {ERR=> "md5sum: h: no properly formatted MD5 checksum lines found\n"}],
);
# Insert the `--text' argument for each test.

View file

@ -1,7 +1,7 @@
Summary: The GNU core utilities: a set of tools commonly used in shell scripts
Name: coreutils
Version: 6.10
Release: 21%{?dist}
Release: 22%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -314,6 +314,10 @@ fi
/sbin/runuser
%changelog
* Tue May 13 2008 Ondrej Vasik <ovasik@redhat.com> - 6.10-22
- checksum line handling fix (#439531) done upstream way
which covers more possible cases
* Fri Apr 18 2008 Ondrej Vasik <ovasik@redhat.com> - 6.10-21
- fix wrong checksum line handling in sha1sum -c
command(#439531)