[Bug 252542] cmp -s + regular files + skipping is broken

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Jan 9 10:35:15 UTC 2021


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252542

            Bug ID: 252542
           Summary: cmp -s + regular files + skipping is broken
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: william at 25thandclement.com

The file length comparison short-circuit in cmp.c for when the -s flag, regular
files, and SKIP1 are specified is broken. c_regular in regular.c had a similar
buggy short-circuit that was fixed in June 2000. But in July 2000 the -z flag
feature was added which accidentally reintroduced the same bug. The bug is
comparing the file sizes without accounting for skip1 and skip2. See
https://svnweb.freebsd.org/base/head/usr.bin/cmp/cmp.c?revision=344551&view=markup#l193
Note that both sflag and zflag are set when -s is specified. 

Discovered when investigating a bug report on the OpenBSD mailing-list. More
detailed dissection at https://marc.info/?l=openbsd-misc&m=161017967207304&w=2

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list