[CVE-2022-40304] Fix dict corruption caused by entity reference cycles 87/287287/1 accepted/tizen_6.5_base accepted/tizen_6.5_base_tool tizen_6.5_base accepted/tizen/6.5/base/20230714.002546 accepted/tizen/6.5/base/tool/20230131.025508 submit/tizen_6.5_base/20230126.073210
authorNick Wellnhofer <wellnhofer@aevum.de>
Wed, 31 Aug 2022 20:11:25 +0000 (22:11 +0200)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 26 Jan 2023 06:59:13 +0000 (15:59 +0900)
commitb7220480b838599f40eae1b6ce7e3a29b9bdb99b
treea784449a7d9f12bb81ba1aed2fb36129f3f3891c
parent6c39c7c75d1f61a3e23750e98bcec9f0aa40473b
[CVE-2022-40304] Fix dict corruption caused by entity reference cycles

When an entity reference cycle is detected, the entity content is
cleared by setting its first byte to zero. But the entity content might
be allocated from a dict. In this case, the dict entry becomes corrupted
leading to all kinds of logic errors, including memory errors like
double-frees.

Stop storing entity content, orig, ExternalID and SystemID in a dict.
These values are unlikely to occur multiple times in a document, so they
shouldn't have been stored in a dict in the first place.

Thanks to Ned Williamson and Nathan Wachholz working with Google Project
Zero for the report!

Change-Id: Ic72980e9951365347f484203817b37fa41e65d52
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
entities.c