1 Star 0 Fork 52

冉召宇/third_party_libxml2_1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backport-malloc-fail-Fix-null-deref-if-growing-input-buffer-fails.patch 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
冉召宇 提交于 11个月前 . libxml2切openEuler7.0
From 2355eac59e91e1465696150cf0efc9029ba4f9b2 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Sun, 22 Jan 2023 14:52:06 +0100
Subject: [PATCH] malloc-fail: Fix null deref if growing input buffer fails
Also add some error checks.
Found with libFuzzer, see #344.
Reference:https://github.com/GNOME/libxml2/commit/2355eac59e91e1465696150cf0efc9029ba4f9b2
Conflict:xmlIO.c
---
encoding.c | 3 ++-
parserInternals.c | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/encoding.c b/encoding.c
index 8ce407f..c073a9c 100644
--- a/encoding.c
+++ b/encoding.c
@@ -2288,7 +2288,8 @@ xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
toconv = 64 * 1024;
written = xmlBufAvail(out);
if (toconv * 2 >= written) {
- xmlBufGrow(out, toconv * 2);
+ if (xmlBufGrow(out, toconv * 2) < 0)
+ return (-1);
written = xmlBufAvail(out);
}
if ((written > 128 * 1024) && (flush == 0))
diff --git a/parserInternals.c b/parserInternals.c
index cee4cd9..dd1dc9c 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -326,6 +326,12 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
ret = xmlParserInputBufferGrow(in->buf, len);
in->base = xmlBufContent(in->buf->buffer);
+ if (in->base == NULL) {
+ in->base = BAD_CAST "";
+ in->cur = in->base;
+ in->end = in->base;
+ return(-1);
+ }
in->cur = in->base + indx;
in->end = xmlBufEnd(in->buf->buffer);
--
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

搜索帮助