md5sum,sha*sum: fix --ignore-missing with checksums starting with 00
This commit is contained in:
parent
21de8b5251
commit
3ed22ec3e8
115
coreutils-8.25-sum-ignore-missing.patch
Normal file
115
coreutils-8.25-sum-ignore-missing.patch
Normal file
@ -0,0 +1,115 @@
|
||||
From 1e1a69da31b39e4d672ccb8a3ca0e5400d4720ee 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
|
||||
|
||||
Upstream-commit: d0ddfadfb27def2861f35b1a45190a4c1780b257
|
||||
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
||||
---
|
||||
src/md5sum.c | 20 ++++++++++++--------
|
||||
tests/misc/md5sum.pl | 7 +++++++
|
||||
2 files changed, 19 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/md5sum.c b/src/md5sum.c
|
||||
index 933ec99..fee28c7 100644
|
||||
--- a/src/md5sum.c
|
||||
+++ b/src/md5sum.c
|
||||
@@ -465,15 +465,19 @@ print_filename (char const *file, bool escape)
|
||||
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;
|
||||
@@ -493,7 +497,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result)
|
||||
{
|
||||
if (ignore_missing && errno == ENOENT)
|
||||
{
|
||||
- *bin_result = '\0';
|
||||
+ *missing = true;
|
||||
return true;
|
||||
}
|
||||
error (0, errno, "%s", quotef (filename));
|
||||
@@ -606,14 +610,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)
|
||||
{
|
||||
@@ -626,10 +630,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
|
||||
@@ -879,8 +882,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
|
||||
{
|
||||
diff --git a/tests/misc/md5sum.pl b/tests/misc/md5sum.pl
|
||||
index 2eb6369..6ea7457 100755
|
||||
--- a/tests/misc/md5sum.pl
|
||||
+++ b/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"}],
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
@ -1,7 +1,7 @@
|
||||
Summary: A set of basic GNU tools commonly used in shell scripts
|
||||
Name: coreutils
|
||||
Version: 8.25
|
||||
Release: 16%{?dist}
|
||||
Release: 17%{?dist}
|
||||
License: GPLv3+
|
||||
Group: System Environment/Base
|
||||
Url: http://www.gnu.org/software/coreutils/
|
||||
@ -23,6 +23,8 @@ Patch952: coreutils-8.25-intall-Z-selinux.patch
|
||||
Patch953: coreutils-8.25-sort-thousands-sep.patch
|
||||
# ls: allow interruption when reading slow directories (#1365933)
|
||||
Patch954: coreutils-8.25-ls-signal.patch
|
||||
# md5sum,sha*sum: fix --ignore-missing with checksums starting with 00
|
||||
Patch955: coreutils-8.25-sum-ignore-missing.patch
|
||||
|
||||
# Our patches
|
||||
#general patch to workaround koji build system issues
|
||||
@ -216,6 +218,7 @@ tee DIR_COLORS{,.256color,.lightbgcolor} <src/dircolors.hin >/dev/null
|
||||
# upstream patches
|
||||
%patch953 -p1
|
||||
%patch954 -p1
|
||||
%patch955 -p1
|
||||
|
||||
chmod a+x \
|
||||
tests/df/direct.sh \
|
||||
@ -345,6 +348,9 @@ fi
|
||||
%license COPYING
|
||||
|
||||
%changelog
|
||||
* Mon Oct 31 2016 Kamil Dudka <kdudka@redhat.com> - 8.25-17
|
||||
- md5sum,sha*sum: fix --ignore-missing with checksums starting with 00
|
||||
|
||||
* Tue Oct 11 2016 Tomáš Mráz <tmraz@redhat.com> - 8.25-16
|
||||
- rebuild with OpenSSL 1.1.0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user