我正在实现一个工具来发现有害的整数溢出。我尝试使用Juliet测试用例套件,但很快发现许多测试用例在我的64位机器上都没有出现安全问题,因为它们采用32位架构。
考虑这个函数,取自CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_44.c:
static void badSink(int data)
{
{
size_t i;
int *intPointer;
/* POTENTIAL FLAW: if data * sizeof(int) > SIZE_MAX, overflows to a small value
* so that the for loop doing the initialization causes a buffer overflow */
intPointer = (int*)malloc(data * sizeof(int));
for (i = 0; i < (size_t)data; i++)
{
intPointer[i] = 0; /* Potentially writes beyond the boundary of intPointer */
}
printIntLine(intPointer[0]);
free(intPointer);
}
}
高值的数据只能在32位架构上溢出,其中size_t参数和int的位宽都为32.在我的64位机器上,int有32位,因此malloc参数永远不会溢出。 / p>
因此我的问题是:朱丽叶套件是否有字宽限制?在自动生成文件时出了什么问题?或者套房是错误的还是过时的?