From bbff9e1ef72e2eab63e5d7ecd5dfa36497b642ed Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Fri, 8 May 2015 21:03:09 +0530 Subject: features/changelog: Fix buffer overflow in snprintf Change-Id: Ie7e7c6028c7bffe47e60a2e93827e0e8767a3d66 BUG: 1219894 Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/10687 Reviewed-by: Aravinda VK Tested-by: Gluster Build System Tested-by: NetBSD Build System --- xlators/features/changelog/src/changelog-helpers.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'xlators/features') diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index bfe7a17a87e..a7d3e955fd2 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -690,13 +690,13 @@ int htime_create (xlator_t *this, changelog_priv_t *priv, unsigned long ts) { - int ht_file_fd = -1; - int ht_dir_fd = -1; - int ret = 0; - char ht_dir_path[PATH_MAX] = {0,}; - char ht_file_path[PATH_MAX] = {0,}; - char ht_file_bname[NAME_MAX] = {0,}; - int flags = 0; + int ht_file_fd = -1; + int ht_dir_fd = -1; + int ret = 0; + char ht_dir_path[PATH_MAX] = {0,}; + char ht_file_path[PATH_MAX] = {0,}; + char ht_file_bname[NAME_MAX + 1] = {0,}; + int flags = 0; CHANGELOG_FILL_HTIME_DIR(priv->changelog_dir, ht_dir_path); @@ -739,7 +739,7 @@ htime_create (xlator_t *this, goto out; } - (void) snprintf (ht_file_bname, PATH_MAX, "%s.%lu", + (void) snprintf (ht_file_bname, sizeof (ht_file_bname), "%s.%lu", HTIME_FILE_NAME, ts); if (sys_fsetxattr (ht_dir_fd, HTIME_CURRENT, ht_file_bname, strlen (ht_file_bname), 0)) { -- cgit