How detect a buffer overflow with splint

176 Views Asked by At

I'm trying to use splint to detect some bug in my code. One of more critical point is the buffer overflow detection and seem that splint is not able to do that. I've tried with a simple C-code

void test()
 {
    int i;
    int a[10]
    for(i=0;i<12;i++)
        a[i]=i;
 }

This code generate a core dump but the Splint log is empty I runned splint with default flag Any suggestion about to detect this ? Thanks

1

There are 1 best solutions below

1
H2O On

+bounds option solve my problem: Possible out-of-bounds store: a[i] Unable to resolve constraint: requires i @ test.c:6:11 <= 9 needed to satisfy precondition: requires maxSet(a @ test.c:6:9) >= i @ test.c:6:11 A memory write may write to an address beyond the allocated buffer. (Use -boundswrite to inhibit warning)

additional info : splint +bounds to run the check I found the flag looking into all flag availbale in splint and get more detail in specific help:

splint --help flags alpha splint --help bounds