5 Star 6 Fork 47

OpenHarmony/third_party_libxml2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
backport-malloc-fail-Fix-infinite-loop-in-htmlParseStartTag1.patch 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
冉召宇 提交于 2024-04-25 19:13 . libxml2切openEuler7.0
From 643b4e90ebf619432b0287010b593edd8c0c0f8e Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <[email protected]>
Date: Thu, 16 Feb 2023 14:45:06 +0100
Subject: [PATCH] malloc-fail: Fix infinite loop in htmlParseStartTag
Found with libFuzzer, see #344.
Reference:https://github.com/GNOME/libxml2/commit/643b4e90ebf619432b0287010b593edd8c0c0f8e
Conflict:NA
---
HTMLparser.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/HTMLparser.c b/HTMLparser.c
index 60dea30..0ccd6e8 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -2570,6 +2570,7 @@ static const xmlChar * htmlParseNameComplex(xmlParserCtxtPtr ctxt);
static const xmlChar *
htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
+ const xmlChar *ret;
int i = 0;
xmlChar loc[HTML_PARSER_BUFFER_SIZE];
@@ -2587,7 +2588,11 @@ htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
NEXT;
}
- return(xmlDictLookup(ctxt->dict, loc, i));
+ ret = xmlDictLookup(ctxt->dict, loc, i);
+ if (ret == NULL)
+ htmlErrMemory(ctxt, NULL);
+
+ return(ret);
}
@@ -4020,7 +4025,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
SKIP_BLANKS;
while ((CUR != 0) &&
(CUR != '>') &&
- ((CUR != '/') || (NXT(1) != '>'))) {
+ ((CUR != '/') || (NXT(1) != '>')) &&
+ (ctxt->instate != XML_PARSER_EOF)) {
GROW;
attname = htmlParseAttribute(ctxt, &attvalue);
if (attname != NULL) {
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/third_party_libxml2.git
[email protected]:openharmony/third_party_libxml2.git
openharmony
third_party_libxml2
third_party_libxml2
master

搜索帮助