coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ordering bug(?) with cksum/hashsum


From: Pádraig Brady
Subject: Re: Ordering bug(?) with cksum/hashsum
Date: Mon, 27 May 2024 16:50:43 +0100
User-agent: Mozilla Thunderbird Beta

On 26/05/2024 22:08, Sylvestre Ledru wrote:
Hello,

Playing with the one of the *sum command, i noticed a weird behavior.

Depending on the order in the checksum file, we will get completely
different results.

For example, this code reproduces the issue:

----

touch a
touch "*c"
echo "First test case:"
echo "d41d8cd98f00b204e9800998ecf8427e *c" > in.md5
echo "d41d8cd98f00b204e9800998ecf8427e a" >> in.md5
/usr/bin/md5sum --check in.md5
echo ""
echo "Second test case:"
echo "d41d8cd98f00b204e9800998ecf8427e a" > in.md5
echo "d41d8cd98f00b204e9800998ecf8427e *c" >> in.md5
/usr/bin/md5sum --check in.md5

----

Will return:
----
First test case:
/usr/bin/md5sum: c: No such file or directory
c: FAILED open or read
/usr/bin/md5sum: WARNING: 1 line is improperly formatted
/usr/bin/md5sum: WARNING: 1 listed file could not be read

Second test case:
a: OK
*c: OK
----

with:
md5sum (GNU coreutils) 9.4

Is that a bug?

I think I understand the technical reason even if I didn't check the
code. I guess the parser will look at the first line
and think that it the "double space format".

It's not a bug, it's an unsupported edge case for auto handling BSD reversed 
format.
The edge case considerations are documented in:
https://github.com/coreutils/coreutils/commit/7da844cc8
To state explicitly, it's only when the first file name presented to --check
in a BSD reversed format checksum file, has a ' ' or '*' first character.
That's quite the edge case, which should not hit in real world use cases.

cheers,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]