代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony/third_party_libxml2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 6fd8904108f23810699d3a242e3612c4ec2f9cf2 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Sun, 22 Jan 2023 19:42:41 +0100
Subject: [PATCH] malloc-fail: Fix use-after-free in xmlParseStartTag2
Fix error handling in xmlCtxtGrowAttrs.
Found with libFuzzer, see #344.
Reference:https://github.com/GNOME/libxml2/commit/6fd8904108f23810699d3a242e3612c4ec2f9cf2
Conflict:NA
---
parser.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/parser.c b/parser.c
index 88f04e4..3aea3e2 100644
--- a/parser.c
+++ b/parser.c
@@ -1715,25 +1715,21 @@ xmlCtxtGrowAttrs(xmlParserCtxtPtr ctxt, int nr) {
int *attallocs;
int maxatts;
- if (ctxt->atts == NULL) {
- maxatts = 55; /* allow for 10 attrs by default */
- atts = (const xmlChar **)
- xmlMalloc(maxatts * sizeof(xmlChar *));
- if (atts == NULL) goto mem_error;
- ctxt->atts = atts;
- attallocs = (int *) xmlMalloc((maxatts / 5) * sizeof(int));
- if (attallocs == NULL) goto mem_error;
- ctxt->attallocs = attallocs;
- ctxt->maxatts = maxatts;
- } else if (nr + 5 > ctxt->maxatts) {
- maxatts = (nr + 5) * 2;
- atts = (const xmlChar **) xmlRealloc((void *) ctxt->atts,
+ if (nr + 5 > ctxt->maxatts) {
+ maxatts = ctxt->maxatts == 0 ? 55 : (nr + 5) * 2;
+ atts = (const xmlChar **) xmlMalloc(
maxatts * sizeof(const xmlChar *));
if (atts == NULL) goto mem_error;
- ctxt->atts = atts;
attallocs = (int *) xmlRealloc((void *) ctxt->attallocs,
(maxatts / 5) * sizeof(int));
- if (attallocs == NULL) goto mem_error;
+ if (attallocs == NULL) {
+ xmlFree(atts);
+ goto mem_error;
+ }
+ if (ctxt->maxatts > 0)
+ memcpy(atts, ctxt->atts, ctxt->maxatts * sizeof(const xmlChar *));
+ xmlFree(ctxt->atts);
+ ctxt->atts = atts;
ctxt->attallocs = attallocs;
ctxt->maxatts = maxatts;
}
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。