command: hashsum: md5sum reports wrong sum for the file named 4k.bin
Peter Mamonov
pmamonov at gmail.com
Thu Dec 21 02:48:11 PST 2017
On Wed, Dec 20, 2017 at 01:48:14PM +0300, Peter Mamonov wrote:
> Hi,
>
> The md5sum command reports wrong sum for a file named 4k.bin and, I guess, for
> other files named alike. Here are the commands to reproduce the bug:
The problem lays in __do_digest() function:
- it initializes variables `start` and `size` at commands/digest.c:38
- then it calls parse_area_spec(*argv, &start, &size) at commands/digest.c:42
- parse_area_spec() returns error as it should, however it changes the value
of the `start` at lib/misc.c:87.
- this causes digest algo to skip leading 4k of the data from the file.
I'm not quite sure what is the best solution:
- prevent parse_area_spec() from setting start if it fails?
- reinitialize start/size after unsuccessfull call to parse_area_spec()?
Regards,
Peter
>
> barebox at barebox sandbox:/ memcpy -s /dev/zero -d _4k.bin 0 0 4k
> barebox at barebox sandbox:/ md5sum _4k.bin
> 620f0b67a91f7f74151bc5be745b7110 _4k.bin
>
> barebox at barebox sandbox:/ cp _4k.bin 4k.bin
> barebox at barebox sandbox:/ md5sum 4k.bin
> d41d8cd98f00b204e9800998ecf8427e 4k.bin
>
> barebox at barebox sandbox:/ cp 4k.bin __4k.bin
> barebox at barebox sandbox:/ md5sum __4k.bin
> 620f0b67a91f7f74151bc5be745b7110 __4k.bin
>
> barebox at barebox sandbox:/ version
>
> barebox 2017.12.0 #4 Wed Dec 20 12:26:57 MSK 2017
>
> barebox at barebox sandbox:/ Terminated
>
> $ dd if=/dev/zero bs=4k count=1 | md5sum
> ...
> 620f0b67a91f7f74151bc5be745b7110 -
>
> Regards,
> Peter
More information about the barebox
mailing list