From 77778274e60363ac4fbf604c74c3fb8075b70eff 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 BUG: 1219823 Change-Id: I3a1c7b7742671847ed3fec13e06d861c3d09f7a9 Reviewed-On: http://review.gluster.org/#/c/10687/ Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/10688 Tested-by: Gluster Build System Reviewed-by: Aravinda VK --- xlators/features/changelog/src/changelog-helpers.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'xlators/features/changelog') 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