]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Add test for malformed "default" ACL prefix (issue #2744) 2859/head
authorzhangjy1014 <60053759+zhangjy1014@users.noreply.github.com>
Mon, 9 Feb 2026 03:20:18 +0000 (11:20 +0800)
committerzhangjy1014 <60053759+zhangjy1014@users.noreply.github.com>
Mon, 9 Feb 2026 03:20:18 +0000 (11:20 +0800)
Verify that archive_entry_acl_from_text() and
archive_entry_acl_from_text_w() return ARCHIVE_WARN instead of
crashing when given a bare "d" or "default" string with no
subsequent tag field.

Without the accompanying fix in archive_acl.c this test triggers
a NULL-pointer dereference (SEGV) in archive_acl_from_text_w().

libarchive/test/test_acl_text.c

index c2904649a3ba4db7e0f3c485bbd8fc4c1c9065bc..7e80686e84eb2c90c0240f0274f8037c3938468f 100644 (file)
@@ -404,6 +404,29 @@ DEFINE_TEST(test_acl_from_text)
        archive_entry_acl_clear(ae);
 
        free(ws);
+
+       /*
+        * 6. Malformed "default" prefix with no tag field should return
+        *    ARCHIVE_WARN, not crash (GitHub issue #2744).
+        *    When the ACL text is just "d" or "default" with type DEFAULT,
+        *    the parser recognises the default prefix but field[1] is NULL,
+        *    which previously caused a NULL-pointer dereference.
+        */
+       archive_entry_acl_clear(ae);
+       assertEqualInt(ARCHIVE_WARN,
+           archive_entry_acl_from_text(ae, "d",
+           ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+       assertEqualInt(ARCHIVE_WARN,
+           archive_entry_acl_from_text_w(ae, L"d",
+           ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+       archive_entry_acl_clear(ae);
+       assertEqualInt(ARCHIVE_WARN,
+           archive_entry_acl_from_text(ae, "default",
+           ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+       assertEqualInt(ARCHIVE_WARN,
+           archive_entry_acl_from_text_w(ae, L"default",
+           ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+
        archive_entry_free(ae);
 }