代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony/third_party_libxml2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 767ae50bc9e94a35bfede3af291cf0060893db0f Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Sun, 5 Mar 2023 14:11:24 +0100
Subject: [PATCH] malloc-fail: Fix null deref after
xmlSchemaItemList{Add,Insert}
Found with libFuzzer, see #344.
Reference:https://github.com/GNOME/libxml2/commit/767ae50bc9e94a35bfede3af291cf0060893db0f
Conflict:NA
---
xmlschemas.c | 44 ++++++++++++++++----------------------------
1 file changed, 16 insertions(+), 28 deletions(-)
diff --git a/xmlschemas.c b/xmlschemas.c
index 46cbe0f..d2f8bf1 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -3417,23 +3417,17 @@ xmlSchemaItemListClear(xmlSchemaItemListPtr list)
static int
xmlSchemaItemListAdd(xmlSchemaItemListPtr list, void *item)
{
- if (list->items == NULL) {
- list->items = (void **) xmlMalloc(
- 20 * sizeof(void *));
- if (list->items == NULL) {
- xmlSchemaPErrMemory(NULL, "allocating new item list", NULL);
- return(-1);
- }
- list->sizeItems = 20;
- } else if (list->sizeItems <= list->nbItems) {
- list->sizeItems *= 2;
- list->items = (void **) xmlRealloc(list->items,
- list->sizeItems * sizeof(void *));
- if (list->items == NULL) {
+ if (list->sizeItems <= list->nbItems) {
+ void **tmp;
+ size_t newSize = list->sizeItems == 0 ? 20 : list->sizeItems * 2;
+
+ tmp = (void **) xmlRealloc(list->items, newSize * sizeof(void *));
+ if (tmp == NULL) {
xmlSchemaPErrMemory(NULL, "growing item list", NULL);
- list->sizeItems = 0;
return(-1);
}
+ list->items = tmp;
+ list->sizeItems = newSize;
}
list->items[list->nbItems++] = item;
return(0);
@@ -3474,23 +3468,17 @@ xmlSchemaItemListAddSize(xmlSchemaItemListPtr list,
static int
xmlSchemaItemListInsert(xmlSchemaItemListPtr list, void *item, int idx)
{
- if (list->items == NULL) {
- list->items = (void **) xmlMalloc(
- 20 * sizeof(void *));
- if (list->items == NULL) {
- xmlSchemaPErrMemory(NULL, "allocating new item list", NULL);
- return(-1);
- }
- list->sizeItems = 20;
- } else if (list->sizeItems <= list->nbItems) {
- list->sizeItems *= 2;
- list->items = (void **) xmlRealloc(list->items,
- list->sizeItems * sizeof(void *));
- if (list->items == NULL) {
+ if (list->sizeItems <= list->nbItems) {
+ void **tmp;
+ size_t newSize = list->sizeItems == 0 ? 20 : list->sizeItems * 2;
+
+ tmp = (void **) xmlRealloc(list->items, newSize * sizeof(void *));
+ if (tmp == NULL) {
xmlSchemaPErrMemory(NULL, "growing item list", NULL);
- list->sizeItems = 0;
return(-1);
}
+ list->items = tmp;
+ list->sizeItems = newSize;
}
/*
* Just append if the index is greater/equal than the item count.
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。