From bdf8d8684fa4814cf055350db38f53618c5de6ae Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Fri, 16 Nov 2018 12:46:49 -0500 Subject: core: fix strncpy, coverity annotation For added fun, coverity is not smart enough to detect that the strncpy() is safe, and for extra laughs, using coverity annotations doesn't do anything either; but we're adding them anyway, along with marking the BUFFER_SIZE_WARNINGS as false positives on scan.coverity.com. Change-Id: If7fa157eca565842109f32fee0399ac183b19ec7 updates: bz#1193929 Signed-off-by: Kaleb S. KEITHLEY --- xlators/mgmt/glusterd/src/glusterd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index bbc9d317a9..e79d281365 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -1825,17 +1825,22 @@ init(xlator_t *this) conf->gfs_mgmt = &gd_brick_prog; this->private = conf; /* conf->workdir and conf->rundir are smaller than PATH_MAX; gcc's - * snprintf checking will throw an error here if sprintf is used. */ + * snprintf checking will throw an error here if sprintf is used. + * Dueling gcc-8 and coverity, now coverity isn't smart enough to + * detect that these strncpy calls are safe. And for extra fun, + * the annotations don't do anything. */ if (strlen(workdir) >= sizeof(conf->workdir)) { ret = -1; goto out; } + /* coverity[BUFFER_SIZE_WARNING] */ (void)strncpy(conf->workdir, workdir, sizeof(conf->workdir)); /* separate tests because combined tests confuses gcc */ if (strlen(rundir) >= sizeof(conf->rundir)) { ret = -1; goto out; } + /* coverity[BUFFER_SIZE_WARNING] */ (void)strncpy(conf->rundir, rundir, sizeof(conf->rundir)); synclock_init(&conf->big_lock, SYNC_LOCK_RECURSIVE); -- cgit