diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c index dcdf60d843..abc3bfe0b0 100644 --- a/libglusterfs/src/client_t.c +++ b/libglusterfs/src/client_t.c @@ -598,10 +598,8 @@ gf_client_dump_fdtables(xlator_t *this) clienttable->cliententries[count].next_free) continue; client = clienttable->cliententries[count].client; - if (client->client_uid) { - gf_proc_dump_build_key(key, "conn", "%d.id", count); - gf_proc_dump_write(key, "%s", client->client_uid); - } + gf_proc_dump_build_key(key, "conn", "%d.id", count); + gf_proc_dump_write(key, "%s", client->client_uid); if (client->subdir_mount) { gf_proc_dump_build_key(key, "conn", "%d.subdir", count); diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index b6c1cc7a1e..829e52b9e9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -58,45 +58,56 @@ gd_mgmt_v3_collate_errors(struct syncargs *args, int op_ret, int op_errno, switch (op_code) { case GLUSTERD_MGMT_V3_LOCK: { - snprintf(op_err, sizeof(op_err), "Locking failed on %s. %s", - peer_str, err_string); + len = snprintf(op_err, sizeof(op_err), + "Locking failed on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_PRE_VALIDATE: { - snprintf(op_err, sizeof(op_err), - "Pre Validation failed on %s. %s", peer_str, - err_string); + len = snprintf(op_err, sizeof(op_err), + "Pre Validation failed on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_BRICK_OP: { - snprintf(op_err, sizeof(op_err), "Brick ops failed on %s. %s", - peer_str, err_string); + len = snprintf(op_err, sizeof(op_err), + "Brick ops failed on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_COMMIT: { - snprintf(op_err, sizeof(op_err), "Commit failed on %s. %s", - peer_str, err_string); + len = snprintf(op_err, sizeof(op_err), + "Commit failed on %s. %s", peer_str, err_string); break; } case GLUSTERD_MGMT_V3_POST_COMMIT: { - snprintf(op_err, sizeof(op_err), "Post commit failed on %s. %s", - peer_str, err_string); + len = snprintf(op_err, sizeof(op_err), + "Post commit failed on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_POST_VALIDATE: { - snprintf(op_err, sizeof(op_err), - "Post Validation failed on %s. %s", peer_str, - err_string); + len = snprintf(op_err, sizeof(op_err), + "Post Validation failed on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_UNLOCK: { - snprintf(op_err, sizeof(op_err), "Unlocking failed on %s. %s", - peer_str, err_string); + len = snprintf(op_err, sizeof(op_err), + "Unlocking failed on %s. %s", peer_str, + err_string); break; } default: - snprintf(op_err, sizeof(op_err), "Unknown error! on %s. %s", - peer_str, err_string); + len = snprintf(op_err, sizeof(op_err), + "Unknown error! on %s. %s", peer_str, + err_string); + } + + gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_OP_FAIL, "%s", + op_err); + if (len >= sizeof(op_err)) { + strcpy(op_err, "Truncated error message, check logfile"); } if (args->errstr) { @@ -110,8 +121,6 @@ gd_mgmt_v3_collate_errors(struct syncargs *args, int op_ret, int op_errno, } else snprintf(err_str, sizeof(err_str), "%s", op_err); - gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_OP_FAIL, "%s", - op_err); args->errstr = gf_strdup(err_str); } diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c index 7f52bc95ff..6d946337e4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c @@ -271,7 +271,7 @@ void glusterd_svc_build_pidfile_path(char *server, char *workdir, char *path, size_t len) { - char dir[PATH_MAX] = {0}; + char dir[VALID_GLUSTERD_PATHMAX] = {0}; GF_ASSERT(len == PATH_MAX); @@ -283,7 +283,7 @@ void glusterd_svc_build_volfile_path(char *server, char *workdir, char *volfile, size_t len) { - char dir[PATH_MAX] = { + char dir[VALID_GLUSTERD_PATHMAX] = { 0, }; @@ -301,7 +301,7 @@ glusterd_svc_build_volfile_path(char *server, char *workdir, char *volfile, void glusterd_svc_build_svcdir(char *server, char *workdir, char *path, size_t len) { - GF_ASSERT(len == PATH_MAX); + GF_ASSERT(len == VALID_GLUSTERD_PATHMAX); snprintf(path, len, "%s/%s", workdir, server); } @@ -309,7 +309,7 @@ glusterd_svc_build_svcdir(char *server, char *workdir, char *path, size_t len) void glusterd_svc_build_rundir(char *server, char *workdir, char *path, size_t len) { - char dir[PATH_MAX] = {0}; + char dir[VALID_GLUSTERD_PATHMAX] = {0}; GF_ASSERT(len == PATH_MAX); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 824b03c4d8..b4682ec9b2 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -7672,10 +7672,14 @@ glusterd_is_path_in_use(char *path, gf_boolean_t *in_use, char **op_errstr) ret = -1; } } else { - snprintf(msg, sizeof(msg), - "parent directory %s is " - "already part of a volume", - curdir); + int z = snprintf(msg, sizeof(msg), + "parent directory %s is " + "already part of a volume", + curdir); + if (z < 0 || z >= sizeof(msg)) { + snprintf(msg, sizeof(msg), "path too big"); + ret = -1; + } } }