[Sheepdog] [PATCH] sheep, journal: check ret before calling into jrnl_handlers

Liu Yuan namei.unix at gmail.com
Wed Aug 31 09:23:13 CEST 2011


From: Liu Yuan <tailai.ly at taobao.com>

We should do this sanity check to avoid possible segmentation
fault or further wrong code path, because in error case,
jrnl_type is incorrect.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/store.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/sheep/store.c b/sheep/store.c
index 79a1af3..d192557 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -2241,6 +2241,8 @@ inline int jrnl_apply_to_target_object(struct jrnl_file_desc *jfd)
 	uint32_t jrnl_type;
 
 	ret = jrnl_get_type_from_file(jfd, &jrnl_type);
+	if (ret)
+		return ret;
 
 	return jrnl_handlers[jrnl_type].apply_to_target_object(jfd);
 }
-- 
1.7.5.1




More information about the sheepdog mailing list