From 85394f676dc4f580d29db7b7a8c3a898a8cc225b Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Tue, 22 Oct 2019 18:31:09 +0200 Subject: [PATCH] tests: testQemuCapsIterate: Don't ignore malformed file names 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 Reviewed-by: Jiri Denemark --- tests/testutilsqemu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 0faa9cb84a..7a2ea3bf4e 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -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 */