possible bug in 'sum' command, with a demo

Kang-Che Sung explorer09 at gmail.com
Thu Sep 22 23:49:50 UTC 2016


On Thu, Sep 22, 2016 at 11:57 PM, Anne Salemme <asalemme at crunchtime.com> wrote:
>
>   I am using BusyBox version v1.22.1 inside MobaXterm, and came across what looks like a bug in the ‘sum’ command…maybe not a bug, but definitely not expected…here is a little demo for you…thanks, I love BusyBox!
>
> Demo shows that given two files with different contents, ‘sum’ gives them an identical checksum, but ‘cksum’ gives them different checksums (as expected).

> [asalemme.asalemme-win7] ➤ ls -l
> total 1
> -rw-r--r--    1 asalemme UsersGrp         8 Sep 22 10:27 demo-107108
> -rw-r--r--    1 asalemme UsersGrp         8 Sep 22 10:27 demo-145146
>
> [asalemme.asalemme-win7] ➤ sum *
> 59944     1 demo-107108
> 59944     1 demo-145146
>
> [asalemme.asalemme-win7] ➤ cksum *
> 2984653705 8 demo-107108
> 1560277601 8 demo-145146
>
> [asalemme.asalemme-win7] ➤ od -c demo-107108
> 0000000   1   0   7   1   0   8  \n  \n
> 0000010
>
> [asalemme.asalemme-win7] ➤ od -c demo-145146
> 0000000   1   4   5   1   4   6  \n  \n
> 0000010

I can't reproduce the same result in the latest BusyBox version from git.
Perhaps this has been fixed already?

Here is what I get:

    $ printf '\1\0\7\1\0\10\n\n' | cksum
    111069432 8
    $ printf '\1\0\7\1\0\10\n\n' | sum
    18961     1
    $ printf '\1\0\7\1\0\10\n\n' | ./busybox cksum
    111069432 8
    $ printf '\1\0\7\1\0\10\n\n' | ./busybox sum
    18961     1
    $ printf '\1\4\5\1\4\6\n\n' | ./busybox sum
    18961     1
    $ printf '\1\4\5\1\4\6\n\n' | sum
    18961     1
    $ printf '\1\4\5\1\4\6\n\n' | ./busybox cksum
    3951495440 8
    $ printf '\1\4\5\1\4\6\n\n' | cksum
    3951495440 8
    $ ./busybox | head -n 1
    BusyBox v1.26.0.git (2016-09-23 07:33:08 CST) multi-call binary.
    $ sum --version | head -n 1
    sum (GNU coreutils) 8.21
    $ cksum --version | head -n 1
    cksum (coreutils) 8.21


More information about the busybox mailing list