summaryrefslogtreecommitdiffstats
path: root/xlators/features/index
diff options
context:
space:
mode:
authorXavi Hernandez <xhernandez@redhat.com>2018-07-06 20:23:35 +0200
committerXavi Hernandez <xhernandez@redhat.com>2018-07-10 16:28:24 +0200
commit6dc5dfef819cad69d6d4b4c1c305efa74236ad84 (patch)
tree6b325caf478689d8113279191ca1916e5f5b32ea /xlators/features/index
parent03f1f5bdc46076178f1afdf8e2a76c5b973fe11f (diff)
Fix compile warnings
This patch fixes compile warnings that appear with newer compilers. The solution applied is only to remove the warnings, but it doesn't always solve the problem in the best way. It assumes that the problem will never happen, as the previous code assumed. Change-Id: I6e8470d6c2e2dbd3bd7d324b5fd2f92ffdc3d6ec updates: bz#1193929 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
Diffstat (limited to 'xlators/features/index')
-rw-r--r--xlators/features/index/src/index.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c
index f39d901d624..86c21e9aa83 100644
--- a/xlators/features/index/src/index.c
+++ b/xlators/features/index/src/index.c
@@ -810,6 +810,7 @@ index_entry_create (xlator_t *this, inode_t *inode, char *filename)
char entry_path[PATH_MAX] = {0};
index_priv_t *priv = NULL;
index_inode_ctx_t *ctx = NULL;
+ int32_t len = 0;
priv = this->private;
@@ -841,10 +842,15 @@ index_entry_create (xlator_t *this, inode_t *inode, char *filename)
ctx->state[ENTRY_CHANGES] = IN;
}
+ len = snprintf (entry_path, sizeof(entry_path), "%s/%s", pgfid_path,
+ filename);
+ if ((len < 0) || (len >= sizeof(entry_path))) {
+ op_errno = EINVAL;
+ goto out;
+ }
+
op_errno = 0;
- snprintf (entry_path, sizeof(entry_path), "%s/%s", pgfid_path,
- filename);
ret = index_link_to_base (this, entry_path, ENTRY_CHANGES_SUBDIR);
out:
if (op_errno)
@@ -860,6 +866,7 @@ index_entry_delete (xlator_t *this, uuid_t pgfid, char *filename)
char pgfid_path[PATH_MAX] = {0};
char entry_path[PATH_MAX] = {0};
index_priv_t *priv = NULL;
+ int32_t len = 0;
priv = this->private;
@@ -870,8 +877,12 @@ index_entry_delete (xlator_t *this, uuid_t pgfid, char *filename)
make_gfid_path (priv->index_basepath, ENTRY_CHANGES_SUBDIR, pgfid,
pgfid_path, sizeof (pgfid_path));
- snprintf (entry_path, sizeof(entry_path), "%s/%s", pgfid_path,
- filename);
+ len = snprintf (entry_path, sizeof(entry_path), "%s/%s", pgfid_path,
+ filename);
+ if ((len < 0) || (len >= sizeof(entry_path))) {
+ op_errno = EINVAL;
+ goto out;
+ }
ret = sys_unlink (entry_path);
if (ret && (errno != ENOENT)) {