summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-fops.c6
-rw-r--r--api/src/glfs.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index ee4271fb4dc..611cb14d9eb 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -3205,8 +3205,7 @@ gf_dirent_to_dirent (gf_dirent_t *gf_dirent, struct dirent *dirent)
dirent->d_namlen = strlen (gf_dirent->d_name);
#endif
- strncpy (dirent->d_name, gf_dirent->d_name, NAME_MAX);
- dirent->d_name[NAME_MAX] = 0;
+ snprintf (dirent->d_name, NAME_MAX, "%s", gf_dirent->d_name);
}
@@ -4679,8 +4678,7 @@ retry:
goto out;
if (loc.path) {
- strncpy (retpath, loc.path, PATH_MAX);
- retpath[PATH_MAX] = 0;
+ snprintf (retpath, PATH_MAX, "%s", loc.path);
}
out:
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 9b8cd4f2d2f..8ae3af61edb 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -1602,6 +1602,7 @@ pub_glfs_sysrq (struct glfs *fs, char sysrq)
{
glusterfs_ctx_t *ctx = NULL;
int ret = 0;
+ int msg_len;
char msg[1024] = {0,}; /* should not exceed 1024 chars */
if (!fs || !fs->ctx) {
@@ -1618,8 +1619,9 @@ pub_glfs_sysrq (struct glfs *fs, char sysrq)
struct glfs_sysrq_help *usage = NULL;
for (usage = glfs_sysrq_help; usage->sysrq; usage++) {
- snprintf (msg + strlen (msg), /* append to msg */
- sizeof (msg) - strlen (msg) - 2,
+ msg_len = strlen(msg);
+ snprintf (msg + msg_len, /* append to msg */
+ sizeof (msg) - msg_len - 2,
/* - 2 for the " " + terminating \0 */
" %s", usage->msg);
}