6 Star 5 Fork 55

OpenHarmony/third_party_e2fsprogs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
0032-e2fsck-fix-potential-fencepost-error-in-e2fsck_shoul.patch 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
f房芷仪 提交于 2024-04-08 10:31 . e2fsprogs升级
From 7464397a0c5df0416a7ef3436747045b36fb7882 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Tue, 9 Aug 2022 10:52:57 -0400
Subject: e2fsck: fix potential fencepost error in
e2fsck_should_rebuild_extents()
The ext2_extent_info.max_depth is zero-based (e.g., it is zero when
the entire extent tree fits in the inode). Hence, if it is equal to
MAX_EXTENT_DEPTH_COUNT we should always rebuild the extent tree to
shorten it.
Also, for 1k block file systems, it's possible for the worst-case
extent tree in its most compact form to have a maximum depth of 6, not
5. So set MAX_EXTENT_DEPTH_COUNT to 8 just to be sure we have plenty
of headroom. (The kernel supports an extent depth up to 2**16, but
e2fsck only keeps statistics up to MAX_EXTENT_DEPTH_COUNT, and if it's
deeper than that, we know that it will be profitable to rebuild the
extent tree in any case.)
Addresses-Coverity-Bug: 1507761
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/e2fsck.h | 2 +-
e2fsck/extents.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 00b20919..75baf2cd 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -233,7 +233,7 @@ typedef struct ea_refcount *ext2_refcount_t;
*/
typedef struct e2fsck_struct *e2fsck_t;
-#define MAX_EXTENT_DEPTH_COUNT 5
+#define MAX_EXTENT_DEPTH_COUNT 8
/*
* This strucutre is used to manage the list of extents in a file. Placing
diff --git a/e2fsck/extents.c b/e2fsck/extents.c
index 86fe00e7..70798f34 100644
--- a/e2fsck/extents.c
+++ b/e2fsck/extents.c
@@ -583,7 +583,7 @@ errcode_t e2fsck_should_rebuild_extents(e2fsck_t ctx,
sizeof(struct ext3_extent);
/* If the extent tree is too deep, then rebuild it. */
- if (info->max_depth > MAX_EXTENT_DEPTH_COUNT) {
+ if (info->max_depth > MAX_EXTENT_DEPTH_COUNT-1) {
pctx->blk = info->max_depth;
op = PR_1E_CAN_COLLAPSE_EXTENT_TREE;
goto rebuild;
--
cgit
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/third_party_e2fsprogs.git
git@gitee.com:openharmony/third_party_e2fsprogs.git
openharmony
third_party_e2fsprogs
third_party_e2fsprogs
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385