From e4c14bccb5abff6dcb8194b0da66dc1e73744256 Mon Sep 17 00:00:00 2001 From: Nandaja Varma Date: Tue, 3 Feb 2015 13:17:04 +0530 Subject: changelog: Fixing buffer overrun coverity issues. Coverity IDs: 1214630 1214631 1214633 1234643 Backport of: http://review.gluster.org/9557 Change-Id: I172c4f49bf651b2324522f9e661023f73ca05339 BUG: 789278 Signed-off-by: Nandaja Varma Reviewed-on: http://review.gluster.org/9557 Tested-by: Gluster Build System Reviewed-by: Sakshi Bansal Reviewed-by: Venky Shankar (cherry picked from commit 7d7b80efe8c745f3ff7de76fc31c4977098cae01) Reviewed-on: http://review.gluster.org/10595 Tested-by: NetBSD Build System Tested-by: Venky Shankar --- xlators/features/changelog/src/changelog-helpers.c | 2 +- xlators/features/changelog/src/changelog-misc.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index 0a29969194e..8dae5efa454 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -313,7 +313,7 @@ htime_update (xlator_t *this, ret = -1; goto out; } - strcpy (changelog_path, buffer); + strncpy (changelog_path, buffer, PATH_MAX); len = strlen (changelog_path); changelog_path[len] = '\0'; /* redundant */ diff --git a/xlators/features/changelog/src/changelog-misc.h b/xlators/features/changelog/src/changelog-misc.h index 6658552ecf1..acec6f675ac 100644 --- a/xlators/features/changelog/src/changelog-misc.h +++ b/xlators/features/changelog/src/changelog-misc.h @@ -83,14 +83,14 @@ } \ } while (0) -#define CHANGELOG_FILL_HTIME_DIR(changelog_dir, path) do { \ - strcpy (path, changelog_dir); \ - strcat (path, "/htime"); \ +#define CHANGELOG_FILL_HTIME_DIR(changelog_dir, path) do { \ + strncpy (path, changelog_dir, sizeof (path) - 1); \ + strcat (path, "/htime"); \ } while(0) -#define CHANGELOG_FILL_CSNAP_DIR(changelog_dir, path) do { \ - strcpy (path, changelog_dir); \ - strcat (path, "/csnap"); \ +#define CHANGELOG_FILL_CSNAP_DIR(changelog_dir, path) do { \ + strncpy (path, changelog_dir, sizeof (path) - 1); \ + strcat (path, "/csnap"); \ } while(0) /** * everything after 'CHANGELOG_TYPE_ENTRY' are internal types -- cgit