NetBSD Problem Report #55916
From www@netbsd.org Sat Jan 9 10:58:50 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 248441A9245
for <gnats-bugs@gnats.NetBSD.org>; Sat, 9 Jan 2021 10:58:50 +0000 (UTC)
Message-Id: <20210109105848.6A6971A9246@mollari.NetBSD.org>
Date: Sat, 9 Jan 2021 10:58:48 +0000 (UTC)
From: william@25thandClement.com
Reply-To: william@25thandClement.com
To: gnats-bugs@NetBSD.org
Subject: cmp -s + regular files + skipping is broken
X-Send-Pr-Version: www-1.0
>Number: 55916
>Category: bin
>Synopsis: cmp -s + regular files + skipping is broken
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jan 09 11:00:01 +0000 2021
>Closed-Date: Thu Jun 10 05:23:40 +0000 2021
>Last-Modified: Thu Jun 10 05:23:40 +0000 2021
>Originator: William Ahern
>Release: MAIN
>Organization:
>Environment:
>Description:
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 https://svnweb.freebsd.org/base/head/usr.bin/cmp/regular.c?revision=61883&view=markup
OpenBSD had the same problem but the fix was just committed today, January 9, 2021. See misc@openbsd.org thread at https://marc.info/?t=161016193400003&r=1&w=2
Note that FreeBSD accidentally reintroduced the same bug a month later (July 2000) when they added -z support. See my report at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252542 Be careful if resync'ing to FreeBSD. DragonflyBSD inherited the FreeBSD regression.
>How-To-Repeat:
Run and compare
$ cmp file1 file2 skip1 skip2
with
$ 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 https://marc.info/?l=openbsd-misc&m=161016188503894&w=2
>Fix:
Move the short-circuit exit in regular.c:c_regular to after len1 and len2 are reduced by skip1 and skip2. See https://svnweb.freebsd.org/base/head/usr.bin/cmp/regular.c?revision=61883&view=markup and https://marc.info/?l=openbsd-misc&m=161017560806516&w=2
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55916 CVS commit: src/usr.bin/cmp
Date: Sat, 9 Jan 2021 10:16:28 -0500
Module Name: src
Committed By: christos
Date: Sat Jan 9 15:16:28 UTC 2021
Modified Files:
src/usr.bin/cmp: regular.c
Log Message:
PR/55916: William Ahern: cmp -s + regular files + skipping is broken
Move test after length is adjusted
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/cmp/regular.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Wed, 09 Jun 2021 01:34:08 +0000
State-Changed-Why:
Did the commit in January fix it?
From: William Ahern <william@25thandclement.com>
To: gnats-bugs@netbsd.org
Cc: dholland@netbsd.org
Subject: Re: bin/55916 (cmp -s + regular files + skipping is broken)
Date: Wed, 9 Jun 2021 18:45:12 -0700
On Wed, Jun 09, 2021 at 01:34:08AM +0000, dholland@NetBSD.org wrote:
> Synopsis: cmp -s + regular files + skipping is broken
>
> State-Changed-From-To: open->feedback
> State-Changed-By: dholland@NetBSD.org
> State-Changed-When: Wed, 09 Jun 2021 01:34:08 +0000
> State-Changed-Why:
> Did the commit in January fix it?
It's been awhile so I've the lost context and whatever little scripts I
might have had lying around debugging it. But it seems to be fixed as
running the new code against the test case reported to openbsd-misc produces
the correct result, unlike the cmp built into NetBSD 8.2 (my most recent
VM).
State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Thu, 10 Jun 2021 05:23:40 +0000
State-Changed-Why:
fixed, thanks for checking
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.