From: zhangjy1014 <60053759+zhangjy1014@users.noreply.github.com> Date: Mon, 9 Feb 2026 03:20:18 +0000 (+0800) Subject: Add test for malformed "default" ACL prefix (issue #2744) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=396b9a973585b799ea9c76494f4b0ef29fb48b99;p=thirdparty%2Flibarchive.git Add test for malformed "default" ACL prefix (issue #2744) 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(). --- diff --git a/libarchive/test/test_acl_text.c b/libarchive/test/test_acl_text.c index c2904649a..7e80686e8 100644 --- a/libarchive/test/test_acl_text.c +++ b/libarchive/test/test_acl_text.c @@ -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); }