]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
test: resolve SonarQube code smell by removing redundant conditional
authorLoboQ1ng <xpess@qq.com>
Fri, 20 Mar 2026 21:57:18 +0000 (21:57 +0000)
committerLoboQ1ng <xpess@qq.com>
Fri, 20 Mar 2026 21:57:18 +0000 (21:57 +0000)
libarchive/test/test_read_format_cab_lzx_oob.c

index 14c89b889b03e2ebff3d38dfbf28385c1bdd3c43..a4c15d62f7890b5ab6b15c154a5ec63234a9dda2 100644 (file)
@@ -28,17 +28,13 @@ DEFINE_TEST(test_read_format_cab_lzx_oob)
 
        /* Read the header of the malformed entry */
        if (ARCHIVE_OK == archive_read_next_header(a, &ae)) {
-               /* * We do NOT assert ARCHIVE_OK here. The file is intentionally malformed.
-                * The goal is to ensure the patched decoder catches the malicious size
-                * and returns an error (ARCHIVE_FATAL or ARCHIVE_WARN) instead of crashing.
-                */
-               if (archive_read_data_block(a, &buff, &size, &offset) == ARCHIVE_OK) {
-                       archive_read_data_skip(a);
-               } else {
-                       /* Even if the first block read fails, force a skip to test state handling */
+                       /* * We attempt to read a block to initialize the LZX state machine.
+                       * We do not assert the result because the file is intentionally malformed.
+                       * Regardless of success or failure, we force a skip to test state handling
+                       * and trigger the vulnerability.
+                       */
+                       archive_read_data_block(a, &buff, &size, &offset);
                        archive_read_data_skip(a);
-               }
-               
                /* * Optional: We could assert that the error string contains our patch message, 
                 * but simply surviving without a segfault/ASAN violation is the primary goal 
                 * for fuzzing regression tests.