Menu

#27 possible overflow in memtst.c

open
nobody
5
2005-08-29
2005-08-29
Anonymous
No

Hunting down some memory test errors I discovered that
the reformatted /proc/meminfo (corrected for in
1.3.1pre1) was giving me junk nint values in memtst.c
compute_nint(). Unfortunately the check vs. ceiling
wasn't working. Looks like some overflow or
signed/unsigned issue. Modified code as below and
works fine.

Original code (same in 1.3.0 and 1.3.1pre1)
from memtst.c compute_nint()

if(nint*sizeof(int) > ceiling*1024*1024) {
nint=(ceiling*1024*1024)/sizeof(int);
}

Modified:

if(nint > (ceiling*1024)*(1024/sizeof(int)) {
nint=(ceiling*1024)*(1024/sizeof(int));
}

Yes the root cause of my problems was /proc/meminfo but
the code SHOULD have caught that and not try to test
more memory than ceiling. This should fix that issue.

Discussion


Log in to post a comment.