render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From 4e7a676e72a6c29440fba9ef7942a0e615cd8707 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <4e7a676e72a6c29440fba9ef7942a0e615cd8707.1377873640.git.jdenemar@redhat.com>
43fe83
From: Peter Krempa <pkrempa@redhat.com>
43fe83
Date: Fri, 16 Aug 2013 15:31:00 +0200
43fe83
Subject: [PATCH] virbitmaptest: Add test for out of bounds condition
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=997906
43fe83
43fe83
Previous patch fixed an issue where, when parsing a bitmap from the
43fe83
string, the bounds of the bitmap weren't checked. That flaw resulted into
43fe83
crashes. This test tests that case to avoid it in the future.
43fe83
43fe83
(cherry picked from commit 7efd5fd1b0225436cbbae1181ab41c2d3eca43f9)
43fe83
---
43fe83
 tests/virbitmaptest.c | 34 ++++++++++++++++++++++++++++++++++
43fe83
 1 file changed, 34 insertions(+)
43fe83
43fe83
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
43fe83
index 8cfd8b5..c56d6fa 100644
43fe83
--- a/tests/virbitmaptest.c
43fe83
+++ b/tests/virbitmaptest.c
43fe83
@@ -464,6 +464,38 @@ cleanup:
43fe83
     return ret;
43fe83
 }
43fe83
 
43fe83
+
43fe83
+/* test out of bounds conditions on virBitmapParse */
43fe83
+static int
43fe83
+test9(const void *opaque ATTRIBUTE_UNUSED)
43fe83
+{
43fe83
+    int ret = -1;
43fe83
+    virBitmapPtr bitmap;
43fe83
+
43fe83
+    if (virBitmapParse("100000000", 0, &bitmap, 20) != -1)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (bitmap)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (virBitmapParse("1-1000000000", 0, &bitmap, 20) != -1)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (bitmap)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (virBitmapParse("1-10^10000000000", 0, &bitmap, 20) != -1)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (bitmap)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    ret = 0;
43fe83
+cleanup:
43fe83
+    return ret;
43fe83
+
43fe83
+}
43fe83
+
43fe83
 static int
43fe83
 mymain(void)
43fe83
 {
43fe83
@@ -485,6 +517,8 @@ mymain(void)
43fe83
         ret = -1;
43fe83
     if (virtTestRun("test8", 1, test8, NULL) < 0)
43fe83
         ret = -1;
43fe83
+    if (virtTestRun("test9", 1, test9, NULL) < 0)
43fe83
+        ret = -1;
43fe83
 
43fe83
     return ret;
43fe83
 }
43fe83
-- 
43fe83
1.8.3.2
43fe83