mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
fix(yutil): strlist_sorted_add should not leave a dangling list
realloc() may move the array before the duplicate check returns early, leaving *strlist pointing at freed memory. Assign the new pointer before inspecting entries. Refs GHSA-v42w-m2h7-fm23.
This commit is contained in:
@@ -72,6 +72,21 @@ static void check_class_selector_over_limit(void)
|
||||
ctest_equal_int("should survive overlong class selector", count, 1);
|
||||
}
|
||||
|
||||
static void check_duplicate_class_selector(void)
|
||||
{
|
||||
char css[560];
|
||||
int i;
|
||||
int count;
|
||||
|
||||
for (i = 0; i < 250; ++i) {
|
||||
css[i * 2] = '.';
|
||||
css[i * 2 + 1] = 'a';
|
||||
}
|
||||
strcpy(css + 500, "{display:block;}");
|
||||
count = parse_chunked_css("parser-security/duplicate", css);
|
||||
ctest_equal_int("should reject duplicate class selector", count, 0);
|
||||
}
|
||||
|
||||
void test_css_parser_security(void)
|
||||
{
|
||||
css_init();
|
||||
@@ -81,4 +96,6 @@ void test_css_parser_security(void)
|
||||
ctest_describe("selector name at limit", check_selector_name_at_limit);
|
||||
ctest_describe("class selector over limit",
|
||||
check_class_selector_over_limit);
|
||||
ctest_describe("duplicate class selector",
|
||||
check_duplicate_class_selector);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user