1 Star 0 Fork 53

冉召宇/third_party_libxml2_1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backport-malloc-fail-Add-more-error-checks-when-parsing-names.patch 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
冉召宇 提交于 2024-04-25 19:13 +08:00 . libxml2切openEuler7.0
From c81d0d04bfbdbccea0c5199bced95a6af961885a Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Fri, 17 Mar 2023 12:39:35 +0100
Subject: [PATCH] malloc-fail: Add more error checks when parsing names
xmlParseName and similar functions must return NULL if an error occurs.
Found by OSS-Fuzz, see #344.
Reference:https://github.com/GNOME/libxml2/commit/c81d0d04bfbdbccea0c5199bced95a6af961885a
Conflict:NA
---
parser.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/parser.c b/parser.c
index 75bd27f..b872d34 100644
--- a/parser.c
+++ b/parser.c
@@ -3355,6 +3355,8 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
XML_MAX_NAME_LENGTH;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
#ifdef DEBUG
nbParseName++;
@@ -3410,6 +3412,8 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
* Handler for more complex cases
*/
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
startPosition = CUR_PTR - BASE_PTR;
c = CUR_CHAR(l);
if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
@@ -3686,6 +3690,8 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
if (count++ > XML_PARSER_CHUNK_SIZE) {
count = 0;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
}
COPY_BUF(l,buf,len,c);
NEXTL(l);
@@ -8791,6 +8797,8 @@ xmlParseQName(xmlParserCtxtPtr ctxt, const xmlChar **prefix) {
const xmlChar *l, *p;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
l = xmlParseNCName(ctxt);
if (l == NULL) {
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ran-zhao-yu/third_party_libxml2_1.git
git@gitee.com:ran-zhao-yu/third_party_libxml2_1.git
ran-zhao-yu
third_party_libxml2_1
third_party_libxml2_1
master

搜索帮助