SHA256
1
0
forked from pool/coreutils

- coreutils-m5sum-sha-sum-fix-ignore-missing-with-00-checksums.patch:

Add upstream patch to fix "md5sum --check --ignore-missing" which
  treated files with checksums starting with "00" as missing.

OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=277
This commit is contained in:
Bernhard Voelker 2016-11-01 10:14:04 +00:00 committed by Git OBS Bridge
parent 838c7971b1
commit ee38374c18
5 changed files with 183 additions and 0 deletions

View File

@ -0,0 +1,157 @@
Upstream patch to fix "md5sum --check --ignore-missing" which treated
files with checksums starting with "00" as missing.
To be removed with coreutils > v8.25.
Test case illustrating the issue:
$ echo 559 > file
$ md5sum file | tee file.md5
000b64c5d808b7ae98718d6a191325b7 file
With the file being intact, md5sum previously issued a misleading error
diagnostic, and returned with exit code 1.
$ md5sum -c --ignore-missing file.md5; echo $?
md5sum: file.md5: no file was verified
1
With the file being changed, md5sum still detected the changed file ("FAILED"),
but still stated that the file was not checked; at least the exit code was okay.
$ echo tampered >> file
$ md5sum -c --ignore-missing file.md5; echo $?
file: FAILED
md5sum: WARNING: 1 computed checksum did NOT match
md5sum: file.md5: no file was verified
1
Original patch:
http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=d0ddfadfb27de
From d0ddfadfb27def2861f35b1a45190a4c1780b257 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Wed, 26 Oct 2016 15:45:01 +0100
Subject: [PATCH] md5sum,sha*sum: fix --ignore-missing with checksums starting
with 00
* NEWS: Mention the fix.
* src/md5sum.c (digest_file): Add a new MISSING parameter to
return whether the file was missing, separately from the digest.
* tests/misc/md5sum.pl: Add a test case.
Fixes http://bugs.gnu.org/24795
---
NEWS | 4 ++++
src/md5sum.c | 20 ++++++++++++--------
tests/misc/md5sum.pl | 7 +++++++
3 files changed, 23 insertions(+), 8 deletions(-)
Index: NEWS
===================================================================
--- NEWS.orig
+++ NEWS
@@ -11,6 +11,10 @@ GNU coreutils NEWS
df now filters the system mount list more efficiently, with 20000
mount entries now being processed in about 1.1s compared to 1.7s.
+ md5sum --check --ignore-missing no longer treats files with checksums
+ starting with "00" as missing. This also affects sha*sum.
+ [bug introduced with the --ignore-missing feature in coreutils-8.25]
+
* Noteworthy changes in release 8.25 (2016-01-20) [stable]
Index: src/md5sum.c
===================================================================
--- src/md5sum.c.orig
+++ src/md5sum.c
@@ -462,15 +462,19 @@ print_filename (char const *file, bool e
text because it was a terminal.
Put the checksum in *BIN_RESULT, which must be properly aligned.
+ Put true in *MISSING if the file can't be opened due to ENOENT.
Return true if successful. */
static bool
-digest_file (const char *filename, int *binary, unsigned char *bin_result)
+digest_file (const char *filename, int *binary, unsigned char *bin_result,
+ bool *missing)
{
FILE *fp;
int err;
bool is_stdin = STREQ (filename, "-");
+ *missing = false;
+
if (is_stdin)
{
have_read_stdin = true;
@@ -490,7 +494,7 @@ digest_file (const char *filename, int *
{
if (ignore_missing && errno == ENOENT)
{
- *bin_result = '\0';
+ *missing = true;
return true;
}
error (0, errno, "%s", quotef (filename));
@@ -603,14 +607,14 @@ digest_check (const char *checkfile_name
'8', '9', 'a', 'b',
'c', 'd', 'e', 'f' };
bool ok;
+ bool missing;
/* Only escape in the edge case producing multiple lines,
to ease automatic processing of status output. */
bool needs_escape = ! status_only && strchr (filename, '\n');
properly_formatted_lines = true;
- *bin_buffer = '\1'; /* flag set to 0 for ignored missing files. */
- ok = digest_file (filename, &binary, bin_buffer);
+ ok = digest_file (filename, &binary, bin_buffer, &missing);
if (!ok)
{
@@ -623,10 +627,9 @@ digest_check (const char *checkfile_name
printf (": %s\n", _("FAILED open or read"));
}
}
- else if (ignore_missing && ! *bin_buffer)
+ else if (ignore_missing && missing)
{
- /* Treat an empty buffer as meaning a missing file,
- which is ignored with --ignore-missing. */
+ /* Ignore missing files with --ignore-missing. */
;
}
else
@@ -876,8 +879,9 @@ main (int argc, char **argv)
else
{
int file_is_binary = binary;
+ bool missing;
- if (! digest_file (file, &file_is_binary, bin_buffer))
+ if (! digest_file (file, &file_is_binary, bin_buffer, &missing))
ok = false;
else
{
Index: tests/misc/md5sum.pl
===================================================================
--- tests/misc/md5sum.pl.orig
+++ tests/misc/md5sum.pl
@@ -149,6 +149,13 @@ my @Tests =
{ERR=>
"md5sum: f.md5: no file was verified\n"},
{EXIT=> 1}],
+ # coreutils-8.25 with --ignore-missing treated checksums starting with 00
+ # as if the file was not present
+ ['check-ignore-missing-6', '--check', '--ignore-missing',
+ {AUX=> {f=> '9t'}},
+ {IN=> {'f.md5' =>
+ "006999e6df389641adf1fa3a74801d9d f\n"}},
+ {OUT=>"f: OK\n"}],
['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1},
{ERR=> "$prog: z: no properly formatted MD5 checksum lines found\n"}],

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Nov 1 09:41:12 UTC 2016 - mail@bernhard-voelker.de
- coreutils-m5sum-sha-sum-fix-ignore-missing-with-00-checksums.patch:
Add upstream patch to fix "md5sum --check --ignore-missing" which
treated files with checksums starting with "00" as missing.
-------------------------------------------------------------------
Thu Jul 28 17:02:53 UTC 2016 - mail@bernhard-voelker.de

View File

@ -140,6 +140,11 @@ Patch705: coreutils-df-hash-in-filter.patch
# to be removed with coreutils > v8.25.
Patch710: coreutils-maint-fix-dependency-of-man-arch.1.patch
# Upstream patch to fix "md5sum --check --ignore-missing" which treated
# files with checksums starting with "00" as missing;
# to be removed with coreutils > v8.25.
Patch715: coreutils-m5sum-sha-sum-fix-ignore-missing-with-00-checksums.patch
# ================================================
%description
These are the GNU core utilities. This package is the union of
@ -185,6 +190,7 @@ the GNU fileutils, sh-utils, and textutils packages.
%patch700
%patch705
%patch710
%patch715
#???## We need to statically link to gmp, otherwise we have a build loop
#???#sed -i s,'$(LIB_GMP)',%%{_libdir}/libgmp.a,g Makefile.in

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Nov 1 09:41:12 UTC 2016 - mail@bernhard-voelker.de
- coreutils-m5sum-sha-sum-fix-ignore-missing-with-00-checksums.patch:
Add upstream patch to fix "md5sum --check --ignore-missing" which
treated files with checksums starting with "00" as missing.
-------------------------------------------------------------------
Thu Jul 28 17:02:53 UTC 2016 - mail@bernhard-voelker.de

View File

@ -140,6 +140,11 @@ Patch705: coreutils-df-hash-in-filter.patch
# to be removed with coreutils > v8.25.
Patch710: coreutils-maint-fix-dependency-of-man-arch.1.patch
# Upstream patch to fix "md5sum --check --ignore-missing" which treated
# files with checksums starting with "00" as missing;
# to be removed with coreutils > v8.25.
Patch715: coreutils-m5sum-sha-sum-fix-ignore-missing-with-00-checksums.patch
# ================================================
%description
These are the GNU core utilities. This package is the union of
@ -185,6 +190,7 @@ the GNU fileutils, sh-utils, and textutils packages.
%patch700
%patch705
%patch710
%patch715
#???## We need to statically link to gmp, otherwise we have a build loop
#???#sed -i s,'$(LIB_GMP)',%%{_libdir}/libgmp.a,g Makefile.in