Subject: Re: Tripwire, NetBSD/Sparc
To: LeRoy C. Miller III <qball@ansic.net>
From: David Brownlee <abs@netbsd.org>
List: port-sparc
Date: 06/30/2000 11:13:31
	To be portable you should probably use:

> +       (void) printf(" %-9.9s %7lld %s", owner, (long long)statbuf.st_size,

	Or if you are happy with 32bit limits:

> +       (void) printf(" %-9.9s %7ld %s", owner, (long)statbuf.st_size,



		David/absolute
				       -- www.netbsd.org: No hype required --

On Wed, 28 Jun 2000, LeRoy C. Miller III wrote:

> Ok, for those interested. ;)
> 
> A list subscriber Brian emailed me an explanation to my problem with tripwire
> seg fualting on NetBSD/Sparc, and I figured I would share it. :)
> 
> Brian's Explanation
> 
> On NetBSD, the st_size field of a statbuf is an off_t (ie: 64 bits).
> The code in question is assuming it is a 32 bit quantity.  The printf
> as it stands will try to dereference the second half of the st_size
> field on the stack as the string for the %s.  Changing the %7d to
> %7lld should help.  It probably needs similar changes in other places
> as well.
> 
> (void) printf(" %-9.9s %7d %s", owner, statbuf.st_size, a_time + 4);
> from utils.c is the printf in question. changing it to %7lld works and it seems
> to run without error (I have yet to run it seriously on a dir other than
> /usr/local/etc (for testing)) I will finish up testing it, but it appears this
> did the trick.
> 
> below is a quick diff -ub you can patch with.
> 
> Much thanks to brian for pointing this out to me. ;)
> 
> START
> --- utils.c     Mon Jul 25 12:23:16 1994
> +++ /root/utils.c       Thu Jun 29 16:24:07 2000
> @@ -697,7 +697,7 @@
>  
>         print_perm((uint32)statbuf.st_mode);
>  
> -       (void) printf(" %-9.9s %7d %s", owner, statbuf.st_size,
> +       (void) printf(" %-9.9s %7lld %s", owner, statbuf.st_size,
>                                                 a_time + 4);
>         printf(" %s\n", name);
> END
> 
> LeRoy C. Miller III
> Network Administrator ANSIC Networks
> Email: qball@ansic.net
> Phone: 610-681-6504
> Whois NIC: LM4772
> http://www.ansic.net <not fully functional yet>
>