[hobbit] overflow in netbsd-meminfo.c

Tracy Di Marco White gendalia at iastate.edu
Thu Nov 13 06:09:11 CET 2008


On Wed, Nov 12, 2008 at 10:43 PM, Rich Smrcina <rsmrcina at wi.rr.com> wrote:
> Tracy Di Marco White wrote:
>>>
>>> That appears to be a bug in netbsd.
>>
>> This is what it appears as in meminfo for one of my 4GB machines:
>> [meminfo]
>> Total:-773
>> Free:2884
>> Swaptotal:4098
>> Swapused:0
>>
>> Since freebsd-meminfo.c seems to be using unsigned long in the same
>> place I modified it, I'm not sure it's a bug only in NetBSD.
>
> The display is a bug, Hobbit's interpretation and use of it is an artifact
> of the bug.
>
> If netbsd doesn't have a fix for this problem, you're patch is the right
> solution.

It looks like the problem is this, then?
# sysctl -a|grep physmem
hw.physmem = -537526272
hw.physmem64 = 3757441024

But if hobbit is using a signed int, which it does seem to be here, I
don't see how hobbit could get it anything but wrong when there's more
than 2 GB of RAM.
Given this code, that's my understanding:
   25 	int physmem;
   67 	printf("Total:%d\n", (physmem / (1024 * 1024)));

So is this also a bug in FreeBSD, as they are also using an unsigned
long, for this and for pagesize?

Could you help me understand why you say this is a bug in NetBSD?

-Tracy



More information about the Xymon mailing list