[sheepdog] [PATCH 1/3] sheep/md: check oid more strictly in oid ieration

Liu Yuan namei.unix at gmail.com
Thu Jan 30 05:47:47 CET 2014


This add some more infomation and useful for debugging if something unexpected
happened.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/md.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sheep/md.c b/sheep/md.c
index e535454..0a2903f 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -198,8 +198,14 @@ static int for_each_object_in_path(const char *path,
 			continue;
 		}
 
-		if (strlen(d->d_name) > 17 && d->d_name[16] == '.')
+		if (strlen(d->d_name) > 17 && d->d_name[16] == '.') {
 			epoch = strtoul(d->d_name + 17, NULL, 10);
+			if (epoch == 0 || epoch == ULONG_MAX) {
+				sd_info("%s ignored, strtoul failed %m",
+					d->d_name);
+				continue;
+			}
+		}
 
 		ret = func(oid, path, epoch, arg);
 		if (ret != SD_RES_SUCCESS)
-- 
1.8.1.2




More information about the sheepdog mailing list