lkml.org 
[lkml]   [2024]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] fs/nilfs2: prevent int overflow in btree binary search
Date
Should prevent int overflow if low + high > INT_MAX in big btree with
nchildren in nilfs_btree_node_lookup() binary search.

Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
---
fs/nilfs2/btree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index 65659fa03..39ee4fe11 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -300,7 +300,7 @@ static int nilfs_btree_node_lookup(const struct nilfs_btree_node *node,
index = 0;
s = 0;
while (low <= high) {
- index = (low + high) / 2;
+ index = low + (high - low) / 2;
nkey = nilfs_btree_node_get_key(node, index);
if (nkey == key) {
s = 0;
--
2.34.1

\
 
 \ /
  Last update: 2024-05-27 16:19    [W:0.041 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site