]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: testQemuCapsIterate: Don't ignore malformed file names
authorAndrea Bolognani <abologna@redhat.com>
Tue, 22 Oct 2019 16:31:09 +0000 (18:31 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 24 Oct 2019 15:21:05 +0000 (17:21 +0200)
If files whose name doesn't follow the expected format are added
to the repository, it's better to make the test suite fail than to
silently ignore them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
tests/testutilsqemu.c

index 0faa9cb84ab8e131db0bc60dbcd3de98c0ecbeae..7a2ea3bf4ec6301c5427956b0fbda1ed7c309650 100644 (file)
@@ -910,7 +910,7 @@ testQemuCapsIterate(const char *suffix,
         goto cleanup;
 
     while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
-        char *tmp = ent->d_name;
+        g_autofree char *tmp = g_strdup(ent->d_name);
         char *base = NULL;
         char *archName = NULL;
 
@@ -918,9 +918,11 @@ testQemuCapsIterate(const char *suffix,
         if (!virStringStripSuffix(tmp, suffix))
             continue;
 
-        /* Find the last dot, moving on if none is present */
-        if (!(archName = strrchr(tmp, '.')))
-            continue;
+        /* Find the last dot */
+        if (!(archName = strrchr(tmp, '.'))) {
+            VIR_TEST_VERBOSE("malformed file name '%s'", ent->d_name);
+            goto cleanup;
+        }
 
         /* The base name is everything before the last dot, and
          * the architecture name everything after it */