mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
virbitmaptest: Add test for out of bounds condition
Previous patch fixed an issue where, when parsing a bitmap from the string, the bounds of the bitmap weren't checked. That flaw resulted into crashes. This test tests that case to avoid it in the future.
This commit is contained in:
parent
536d38128e
commit
7efd5fd1b0
@ -464,6 +464,38 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* test out of bounds conditions on virBitmapParse */
|
||||||
|
static int
|
||||||
|
test9(const void *opaque ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
virBitmapPtr bitmap;
|
||||||
|
|
||||||
|
if (virBitmapParse("100000000", 0, &bitmap, 20) != -1)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (bitmap)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virBitmapParse("1-1000000000", 0, &bitmap, 20) != -1)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (bitmap)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virBitmapParse("1-10^10000000000", 0, &bitmap, 20) != -1)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (bitmap)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
@ -485,6 +517,8 @@ mymain(void)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
if (virtTestRun("test8", 1, test8, NULL) < 0)
|
if (virtTestRun("test8", 1, test8, NULL) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
if (virtTestRun("test9", 1, test9, NULL) < 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user