[Sheepdog] [PATCH v5 05/17] sheep: check object directory path at start-up

Liu Yuan namei.unix at gmail.com
Fri Dec 30 14:07:00 CET 2011


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

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

diff --git a/sheep/store.c b/sheep/store.c
index 0025252..201dbb5 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -1862,7 +1862,14 @@ int init_base_path(const char *d)
 
 static int init_obj_path(const char *base_path)
 {
-	int new;
+	int new, len;
+
+	len = strlen(base_path);
+	/* farm needs extra 43 chars to store snapshot objects */
+	if (len + 43 > PATH_MAX) {
+		eprintf("insanely long object directory %s", base_path);
+		return -1;
+	}
 
 	obj_path = zalloc(strlen(base_path) + strlen(OBJ_PATH) + 1);
 	sprintf(obj_path, "%s" OBJ_PATH, base_path);
-- 
1.7.8.rc3




More information about the sheepdog mailing list