summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2018-08-22 18:49:49 -0700
committerAmar Tumballi <amarts@redhat.com>2018-08-25 17:44:02 +0000
commit0e5ff35f1e328a61a85cf0e04ba125a6c72b4069 (patch)
treeb40e0a9187d00871262930883404d88be2a730e7
parent14ee864f8b573d1bccf4f586450947ba4aa690a9 (diff)
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>
-rw-r--r--xlators/storage/posix/src/posix-handle.c17
1 files changed, 12 insertions, 5 deletions
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);