From 0e5ff35f1e328a61a85cf0e04ba125a6c72b4069 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Wed, 22 Aug 2018 18:49:49 -0700 Subject: storage/posix: Coverity fixes in posix-handle.c Addresses the following CIDs: 1370938: Out of bounds write in posix_make_ancestryfromgfid() 1351642: UnChecked return value from sys_stat() in posix_handle_init() Change-Id: I3483ebcd798793ce6c504e92b4ea203bcf99fc0e Updates: bz#789278 Signed-off-by: Vijay Bellur --- xlators/storage/posix/src/posix-handle.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'xlators') diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c index ed95b04b69c..2c88bc63809 100644 --- a/xlators/storage/posix/src/posix-handle.c +++ b/xlators/storage/posix/src/posix-handle.c @@ -148,10 +148,10 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, struct iatt iabuf = {0, }; int ret = -1; uuid_t tmp_gfid = {0, }; - char *dir_stack[PATH_MAX/2]; /* Since PATH_MAX/2 also gives - an upper bound on depth of - directories tree */ - uuid_t gfid_stack[PATH_MAX/2]; + char *dir_stack[PATH_MAX/2 + 1]; /* Since PATH_MAX/2 also gives + an upper bound on depth of + directories tree */ + uuid_t gfid_stack[PATH_MAX/2 + 1]; char *dir_name = NULL; char *saved_dir = NULL; @@ -574,7 +574,14 @@ posix_handle_init (xlator_t *this) break; } - sys_stat (handle_pfx, &priv->handledir); + ret = sys_stat (handle_pfx, &priv->handledir); + + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_HANDLE_CREATE, + "stat for %s failed", handle_pfx); + return -1; + } + MAKE_HANDLE_ABSPATH(rootstr, this, gfid); -- cgit