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 <vbellur@redhat.com>
This commit is contained in:
Vijay Bellur 2018-08-22 18:49:49 -07:00 committed by Amar Tumballi
parent 14ee864f8b
commit 0e5ff35f1e

View File

@ -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);