NetBSD Problem Report #19391

Received: (qmail 6272 invoked by uid 605); 15 Dec 2002 07:09:20 -0000
Message-Id: <200212150709.gBF79IWW026623@edge.twig.com>
Date: Sun, 15 Dec 2002 07:09:17 +0000
From: rad@twig.com (Richard Doty)
Sender: gnats-bugs-owner@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: tripwire dumps core on sparc64 +fix
X-Send-Pr-Version: 3.95

>Number:         19391
>Category:       pkg
>Synopsis:       tripwire dumps core on sparc64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 15 07:10:00 +0000 2002
>Closed-Date:    Tue Dec 09 19:23:57 +0000 2003
>Last-Modified:  Tue Dec 09 19:23:57 +0000 2003
>Originator:     rad@twig.com
>Release:        NetBSD 1.6
>Organization:
>Environment:
System: NetBSD margin 1.6 NetBSD 1.6 (GENERIC) #0: Sun Sep 8 11:55:46 UTC 2002 autobuild@cs20.apochromatic.org:/autobuilder/build/sparc64/OBJ/autobuilder/build/src/sys/arch/sparc64/compile/GENERIC sparc64
Architecture: sparc64
Machine: sparc64
>Description:
	running /usr/pkg/sbin/tripwire on an existing database on
	Sun Ultra-2 causes tripwire to dump core with a seg fault
>How-To-Repeat:
	cd /usr/pkg/etc/tripwire && /usr/pkg/sbin/tripwire
>Fix:
	The problem is that scanf in preen.report.c is using
	a format string that is not consistent with the data
	values it is writing to.

	I include two patches which together fix this problem;
	the first patch alters the format string to expect
	entrynum to be an integer, and the second changes the
	rest of the problem data values to longs so they match
	the format string.

	I could have changed all the format string to ints, or
	changed all the variables to longs, and also solved the
	core file.

	I chose to leave entrynum an integer because it is used
	multiple places as an int; rather than change all those
	other places it was simpler to alter the format string.
	The other values are longs in real life, so it seemed
	appropriate to leave them as long, rather than changing
	all of the format string to int.  Someone else might prefer
	another approach.

patch-local-aa:

--- include/tripwire.h.orig	Sun Dec 15 02:42:42 2002
+++ include/tripwire.h	Sun Dec 15 03:32:47 2002
@@ -67,7 +67,7 @@
  *		ltob64(statbuf->st_ctime, vec64_c), sig0, sig1, ..., sig9
  */

-# define DB_RECORD_FORMAT "%ld %s %lo %lu %lu %lu %lu %lu %s %s %s %s %s %s %s %s %s %s %s %s %s\n"
+# define DB_RECORD_FORMAT "%d %s %lo %lu %lu %lu %lu %lu %s %s %s %s %s %s %s %s %s %s %s %s %s\n"
 #define DB_RECORD_FIELDS 21

 /* system defaults */


patch-local-ab:
--- src/preen.report.c.orig	Thu Aug  4 03:44:34 1994
+++ src/preen.report.c	Sun Dec 15 03:17:37 2002
@@ -452,7 +452,7 @@
     char *s;
     int ignoremask;
     char ignorevec[512];
-    uint32 mode, ino, nlink, uid, gid, size;
+    long mode, ino, nlink, uid, gid, size;
     int entrynum;
     int nfields;

@@ -633,7 +633,7 @@
 {
     char *ignorevec;
     static char structstat_fill_string[512];
-    uint32        mode, ino, nlink, uid, gid, size;
+    long        mode, ino, nlink, uid, gid, size;
     int entrynum;
     char vec64_a[50], vec64_m[50], vec64_c[50];

>Release-Note:
>Audit-Trail:

From: Ben Collver <ben@netbsd.org>
To: gnats-bugs@gnats.netbsd.org, rad@twig.com
Cc:  
Subject: Re: pkg/19391
Date: Wed, 3 Dec 2003 16:55:39 -0800

 I duplicated the problem on sparc64.
 I tested your patches, and they work fine on sparc64 and i386.

 My plan is to:
 	First focus on PR 23640
 	Then look at your patches more closely
 	Then get approval to commit the patches

 Best Regards,

 Ben
 -- 
 NetBSD: It's everywhere you want to be.

From: Ben Collver <ben@netbsd.org>
To: gnats-bugs@gnats.netbsd.org, rad@twig.com
Cc: wiz@netbsd.org, masao@netbsd.org
Subject: Re: pkg/19391
Date: Fri, 5 Dec 2003 10:12:23 -0800

 Hi Rad,

 I took a look at tripwire on sparc64 today.  In include/config.h, uint32 is
 defined by default as an unsigned long.  Hoewever, in revision 1.3 of
 patches/patch-aa, for an "LP64 fix.", -DTW_TYPE32='int' is added to CFLAGS.

 This caused two problems:
         1) The format string in include/tripwire.h was not updated to match.
         2) On NetBSD, off_t is __int64_t.

 Included in this message is my proposed fix, which works on i386 and
 sparc64.  Could you cvs update tripwire, fetch and apply
 http://backyard.homeunix.net:8080/~ben/pkgsrc/tripwire-format.diff
 and see if it works for you?

 Thank you,

 Ben
 -- 
 NetBSD: It's everywhere you want to be.


 Index: distinfo
 ===================================================================
 RCS file: /cvsroot/pkgsrc/security/tripwire/distinfo,v
 retrieving revision 1.6
 diff -u -r1.6 distinfo
 --- distinfo	5 Dec 2003 05:40:32 -0000	1.6
 +++ distinfo	5 Dec 2003 18:06:19 -0000
 @@ -11,3 +11,5 @@
  SHA1 (patch-ag) = 3bfc6965782d727b6b5cf20da4dd44e45327925f
  SHA1 (patch-ah) = 97eccc44190e165dbf174f04c3acab5f1b442bc7
  SHA1 (patch-ai) = 51075e32a7523a8d1691aa41336fe46b671fa865
 +SHA1 (patch-aj) = 5cdda611fe28abf5a98222998ae8a8d0c13e8901
 +SHA1 (patch-ak) = 3f60f374f4163b8af1215a05cd8760a4b655bdc1
 Index: patches/patch-aj
 ===================================================================
 RCS file: patches/patch-aj
 diff -N patches/patch-aj
 --- /dev/null	1 Jan 1970 00:00:00 -0000
 +++ patches/patch-aj	5 Dec 2003 18:06:19 -0000
 @@ -0,0 +1,13 @@
 +$NetBSD$
 +
 +--- include/tripwire.h.orig	1994-07-25 09:04:34.000000000 -0700
 ++++ include/tripwire.h
 +@@ -67,7 +67,7 @@
 +  *		ltob64(statbuf->st_ctime, vec64_c), sig0, sig1, ..., sig9
 +  */
 + 
 +-# define DB_RECORD_FORMAT "%ld %s %lo %lu %lu %lu %lu %lu %s %s %s %s %s %s %s %s %s %s %s %s %s\n"
 ++# define DB_RECORD_FORMAT "%d %s %o %u %u %u %u %zd %s %s %s %s %s %s %s %s %s %s %s %s %s\n"
 + #define DB_RECORD_FIELDS 21
 + 
 + /* system defaults */
 Index: patches/patch-ak
 ===================================================================
 RCS file: patches/patch-ak
 diff -N patches/patch-ak
 --- /dev/null	1 Jan 1970 00:00:00 -0000
 +++ patches/patch-ak	5 Dec 2003 18:06:19 -0000
 @@ -0,0 +1,24 @@
 +$NetBSD$
 +
 +--- src/preen.report.c.orig	1994-08-03 20:44:34.000000000 -0700
 ++++ src/preen.report.c
 +@@ -452,7 +452,8 @@ preen_change_count()
 +     char *s;
 +     int ignoremask;
 +     char ignorevec[512];
 +-    uint32 mode, ino, nlink, uid, gid, size;
 ++    uint32 mode, ino, nlink, uid, gid;
 ++    off_t size;
 +     int entrynum;
 +     int nfields;
 + 
 +@@ -633,7 +634,8 @@ structstat_fill (string, statbuf, sigs, 
 + {
 +     char *ignorevec;
 +     static char structstat_fill_string[512];
 +-    uint32        mode, ino, nlink, uid, gid, size;
 ++    uint32        mode, ino, nlink, uid, gid;
 ++    off_t size;
 +     int entrynum;
 +     char vec64_a[50], vec64_m[50], vec64_c[50];
 + 

From: Ben Collver <collver1@comcast.net>
To: wiz@netbsd.org, uebayasi@netbsd.org, gnats-bugs@gnats.netbsd.org
Cc:  
Subject: Re: pkg/19391
Date: Fri, 5 Dec 2003 13:44:53 -0800

 I changed the format string for off_t from %zd to %jd, which I think is
 more correct.  See:
 http://mail-index.netbsd.org/tech-misc/2003/01/
 http://www.geocrawler.com/mail/thread.php3?subject=proper+printf+fmt+type+for+off_t%3F&list=159

 Cheers,

 Ben

From: Ben Collver <ben@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/19391 CVS commit: pkgsrc/security/tripwire
Date: Tue,  9 Dec 2003 15:56:57 +0000 (UTC)

 Module Name:	pkgsrc
 Committed By:	ben
 Date:		Tue Dec  9 15:56:57 UTC 2003

 Modified Files:
 	pkgsrc/security/tripwire: Makefile distinfo
 Added Files:
 	pkgsrc/security/tripwire/patches: patch-aj patch-ak

 Log Message:
 In include/config.h, uint32 was by default defined as an unsigned long.
 However (because of -DTW_TYPE32='int' being added to CFLAGS for an LP64 fix
 in revision 1.3 of patches/patch-aa) uint32 is defined as an unsigned int.
 This caused two problems:
 1) The format string in include/tripwire.h was not updated to match.
 2) On NetBSD, off_t is __int64_t.

 I am changing the format string in tripwire.h to match uint32.  I also
 changed the type of the variable "size" from uint32 to off_t, and changed
 its format string to match intmax_t.

 This fixes the sparc64 coredump mentioned in PR 19391.


 To generate a diff of this commit:
 cvs rdiff -r1.18 -r1.19 pkgsrc/security/tripwire/Makefile
 cvs rdiff -r1.6 -r1.7 pkgsrc/security/tripwire/distinfo
 cvs rdiff -r0 -r1.1 pkgsrc/security/tripwire/patches/patch-aj \
     pkgsrc/security/tripwire/patches/patch-ak

 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: ben 
State-Changed-When: Tue Dec 9 15:59:46 UTC 2003 
State-Changed-Why:  
I committed a fix for the sparc64 crash.  Could you cvs update tripwire and 
verify that this works for you?  Thank you, 

Ben 

From: rad@twig.com (Richard Doty)
To: gnats-bugs@gnats.netbsd.org
Cc: ben@netbsd.org, pkg-manager@netbsd.org
Subject: Re: pkg/19391 
Date: Tue, 09 Dec 2003 16:47:27 +0000

 On 9 Dec 2003 16:02:31 -0000  ben@netbsd.org wrote:
 > Synopsis: tripwire dumps core on sparc64
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: ben
 > State-Changed-When: Tue Dec 9 15:59:46 UTC 2003
 > State-Changed-Why: 
 > I committed a fix for the sparc64 crash.  Could you cvs update tripwire and
 > verify that this works for you?  Thank you,

 sorry for the delayed response.  I'm not running sparc64 now, so I
 cannot check your change for you.

 Richard

 > 
 > Ben
 > 

From: Ben Collver <collver1@comcast.net>
To: gnats-bugs@gnats.netbsd.org, uebayasi@netbsd.org, wiz@netbsd.org
Cc:  
Subject: Re: pkg/19391
Date: Tue, 9 Dec 2003 10:33:44 -0800

 I just determined this commit will break the build on some versions of
 NetBSD, FreeBSD, and SunOS.  I am working out a more correct fix.

 Ben
State-Changed-From-To: feedback->closed 
State-Changed-By: ben 
State-Changed-When: Tue Dec 9 19:21:59 UTC 2003 
State-Changed-Why:  
Klaus Klein verified the fix works on sparc64. 

I committed another change for portability reasons. 

Thank you very much for this PR. 

Ben 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.