1 Star 0 Fork 48

冉召宇/third_party_libxml2_1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backport-regexp-Add-sanity-check-in-xmlRegCalloc2.patch 965 Bytes
一键复制 编辑 原始数据 按行查看 历史
冉召宇 提交于 2024-04-25 19:13 . libxml2切openEuler7.0
From 85057e513111f69f5a8af94f3a82899d23d4c057 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Tue, 21 Feb 2023 15:24:19 +0100
Subject: [PATCH] regexp: Add sanity check in xmlRegCalloc2
These arguments should be non-zero, but add a sanity check to avoid
division by zero.
Fixes #450.
Reference:https://github.com/GNOME/libxml2/commit/85057e513111f69f5a8af94f3a82899d23d4c057
Conflict:NA
---
xmlregexp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xmlregexp.c b/xmlregexp.c
index e7c48a4..cc4ae6f 100644
--- a/xmlregexp.c
+++ b/xmlregexp.c
@@ -443,7 +443,8 @@ xmlRegCalloc2(size_t dim1, size_t dim2, size_t elemSize) {
void *ret;
/* Check for overflow */
- if (dim1 > SIZE_MAX / dim2 / elemSize)
+ if ((dim2 == 0) || (elemSize == 0) ||
+ (dim1 > SIZE_MAX / dim2 / elemSize))
return (NULL);
totalSize = dim1 * dim2 * elemSize;
ret = xmlMalloc(totalSize);
--
2.27.0
马建仓 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

搜索帮助