[sheepdog] [PATCH] lib: insert assert() to sd_strerror() for detecting invalid index
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Thu Aug 22 08:06:35 CEST 2013
Commit a4d01de did wrong treatment of request data structure. And
it caused segfault in sd_strerror() because of invalid index of the desc
array. This patch insert assert() for detecting such a bug.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
include/sheep.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/sheep.h b/include/sheep.h
index 1d146bd..d708122 100644
--- a/include/sheep.h
+++ b/include/sheep.h
@@ -242,6 +242,8 @@ static inline const char *sd_strerror(int err)
[SD_RES_CLUSTER_ERROR] = "Cluster driver error",
};
+ assert(0 <= err && err < ARRAY_SIZE(descs));
+
if (descs[err] == NULL) {
static __thread char msg[32];
snprintf(msg, sizeof(msg), "Invalid error code %x", err);
--
1.7.10.4
More information about the sheepdog
mailing list