* [PATCH][btrfs-progs] Prevent a SIGSEGV by returning -1 from btrfs_search_slot()
@ 2010-08-19 9:28 Surbhi Palande
2010-08-19 10:15 ` Mike Fedyk
0 siblings, 1 reply; 2+ messages in thread
From: Surbhi Palande @ 2010-08-19 9:28 UTC (permalink / raw)
To: linux-btrfs
https://launchpad.net/bugs/601877
btrfs_search_slot() returns
* -1 when some error is encountered
* +1 when the item to be searched is not found
* 0 when the item is found successfully.
Now, read_node_slot() fails due to an I/O error or due to a malloc failure.
When read_node_slot() cannot read the item to be searched, then
btrfs_search_slot() should return a -1 and not +1 as it was originally
returning. The caller of btrfs_search_slot() expects that on +1, the path[] is
appropriately populated. But due to the error in read_node_slot(), path[] is
not getting populated. Accessing the unpopulated path[] leads to a segfault.
Signed-off-by: Surbhi Palande <surbhi.palande@canonical.com>
---
ctree.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/ctree.c b/ctree.c
index f70e10c..8ec7bf8 100644
--- a/ctree.c
+++ b/ctree.c
@@ -1264,6 +1264,9 @@ again:
key->objectid);
b = read_node_slot(root, b, slot);
+ if (!b) {
+ return -1;
+ }
} else {
p->slots[level] = slot;
if (ins_len > 0 &&
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][btrfs-progs] Prevent a SIGSEGV by returning -1 from btrfs_search_slot()
2010-08-19 9:28 [PATCH][btrfs-progs] Prevent a SIGSEGV by returning -1 from btrfs_search_slot() Surbhi Palande
@ 2010-08-19 10:15 ` Mike Fedyk
0 siblings, 0 replies; 2+ messages in thread
From: Mike Fedyk @ 2010-08-19 10:15 UTC (permalink / raw)
To: Surbhi Palande; +Cc: linux-btrfs
On Thu, Aug 19, 2010 at 2:28 AM, Surbhi Palande
<surbhi.palande@canonical.com> wrote:
> https://launchpad.net/bugs/601877
>
> btrfs_search_slot() returns
> * -1 when some error is encountered
> * +1 when the item to be searched is not found
> * 0 when the item is found successfully.
>
Any chance you can add some defines for these values?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-08-19 10:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-19 9:28 [PATCH][btrfs-progs] Prevent a SIGSEGV by returning -1 from btrfs_search_slot() Surbhi Palande
2010-08-19 10:15 ` Mike Fedyk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).