Subject: pkg/19391: tripwire dumps core on sparc64 +fix
To: None <gnats-bugs@gnats.netbsd.org>
From: Richard Doty <rad@twig.com>
List: netbsd-bugs
Date: 12/15/2002 07:09:17
>Number:         19391
>Category:       pkg
>Synopsis:       tripwire dumps core on sparc64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 14 23:10:00 PST 2002
>Closed-Date:
>Last-Modified:
>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:
>Unformatted: