NetBSD-Bugs archive

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

bin/55916: cmp -s + regular files + skipping is broken

>Number:         55916
>Category:       bin
>Synopsis:       cmp -s + regular files + skipping is broken
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 09 11:00:01 +0000 2021
>Originator:     William Ahern
>Release:        MAIN
NetBSD failed to pick-up a June 2000 (20-year-old) FreeBSD bugfix to the short-circuit in regular.c:c_regular of cmp(1). See

OpenBSD had the same problem but the fix was just committed today, January 9, 2021. See thread at

Note that FreeBSD accidentally reintroduced the same bug a month later (July 2000) when they added -z support. See my report at Be careful if resync'ing to FreeBSD. DragonflyBSD inherited the FreeBSD regression.

Run and compare

$ cmp file1 file2 skip1 skip2


$ cmp -s file1 file2 skip1 skip2

where file1 and file2 are regular files, skip1 and skip2 are different, and cmp should be expected to succeed with exit status 0 because the trailing data is identical. The former succeeds but the latter (cmp -s) will fail.

See example code snippet in original OpenBSD report at

Move the short-circuit exit in regular.c:c_regular to after len1 and len2 are reduced by skip1 and skip2. See and

Home | Main Index | Thread Index | Old Index