From mellon@happy.checkpoint.com  Tue May 16 05:20:02 2000
Return-Path: <mellon@happy.checkpoint.com>
Received: from happy.checkpoint.com (happy.checkpoint.com [199.203.156.41])
	by hub.freebsd.org (Postfix) with ESMTP id 678D137B77B
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 May 2000 05:19:51 -0700 (PDT)
	(envelope-from mellon@happy.checkpoint.com)
Received: (from mellon@localhost)
	by happy.checkpoint.com (8.9.3/8.9.3) id PAA06082;
	Tue, 16 May 2000 15:20:42 GMT
	(envelope-from mellon)
Message-Id: <200005161520.PAA06082@happy.checkpoint.com>
Date: Tue, 16 May 2000 15:20:42 GMT
From: mellon@pobox.com
Sender: mellon@happy.checkpoint.com
Reply-To: mellon@pobox.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: cmp(1) failure
X-Send-Pr-Version: 3.2

>Number:         18597
>Category:       bin
>Synopsis:       cmp(1) failure
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    ps
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 16 05:20:05 PDT 2000
>Closed-Date:    Mon Apr 08 06:46:47 PDT 2002
>Last-Modified:  Mon Apr 08 06:46:47 PDT 2002
>Originator:     Anatoly Vorobey
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:

5.0-CURRENT

>Description:

cmp -s will produce incorrect results when skips are given.

This one appears to have been with us since ancient times.

>How-To-Repeat:

bash-2.03$ cat >f1
abc
bash-2.03$ cat >f2
bc
bash-2.03$ cmp f1 f2 1 0
bash-2.03$ echo $?
0
bash-2.03$ cmp -s f1 f2 1 0
bash-2.03$ echo $?
1

>Fix:

Note that eofmsg() checks sflag, so moving the
test is okay.

I have verified that cmp(1) on Solaris behaves
identically in the test above.

Note 1 -> DIFF_EXIT .

Index: regular.c
===================================================================
RCS file: /freebsd/cvs/src/usr.bin/cmp/regular.c,v
retrieving revision 1.9
diff -u -r1.9 regular.c
--- regular.c	2000/05/15 08:43:25	1.9
+++ regular.c	2000/05/16 15:12:42
@@ -65,15 +65,15 @@
 	off_t pagemask, off1, off2;
 	size_t pagesize;
 
-	if (sflag && len1 != len2)
-		exit(1);
-
 	if (skip1 > len1)
 		eofmsg(file1);
 	len1 -= skip1;
 	if (skip2 > len2)
 		eofmsg(file2);
 	len2 -= skip2;
+
+	if(sflag && len1 != len2)
+		exit(DIFF_EXIT);
 
 	pagesize = getpagesize();
 	pagemask = (off_t)pagesize - 1;



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ps 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Thu Jul 20 04:20:27 PDT 2000 
Responsible-Changed-Why:  
Paul has fixed this in HEAD and RELENG_4.  Since I'm not sure 
whether he plans to merge the fix onto RELENG_3, I'm leaving 
the PR for him to close. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=18597 
State-Changed-From-To: open->analyzed 
State-Changed-By: asmodai 
State-Changed-When: Mon Apr 8 06:13:35 PDT 2002 
State-Changed-Why:  
Committed to RELENG_3 as well. 

Thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=18597 
State-Changed-From-To: analyzed->closed 
State-Changed-By: asmodai 
State-Changed-When: Mon Apr 8 06:46:10 PDT 2002 
State-Changed-Why:  
This should have been closed, not analyzed. 

For the record it was not ps, but green who committed those changes. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=18597 
>Unformatted:
