From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx>
Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
---
:100644 100644 2b8c136... 0f37d3e... M tools/corosync-quorumtool.c
tools/corosync-quorumtool.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c
index 2b8c136..0f37d3e 100644
--- a/tools/corosync-quorumtool.c
+++ b/tools/corosync-quorumtool.c
@@ -142,10 +142,9 @@ static void show_usage(const char *name)
static int get_quorum_type(char *quorum_type, size_t quorum_type_len)
{
int err;
- char *str;
+ char *str = NULL;
if ((!quorum_type) || (quorum_type_len <= 0)) {
- errno = EINVAL;
return -1;
}
@@ -157,6 +156,10 @@ static int get_quorum_type(char *quorum_type, size_t quorum_type_len)
goto out;
}
+ if (!str) {
+ return -1;
+ }
+
strncpy(quorum_type, str, quorum_type_len - 1);
free(str);
@@ -174,6 +177,8 @@ static int using_votequorum(void)
char quorumtype[256];
int using_voteq;
+ memset(quorumtype, 0, sizeof(quorumtype));
+
if (get_quorum_type(quorumtype, sizeof(quorumtype))) {
return -1;
}
@@ -311,14 +316,16 @@ static int display_quorum_data(int is_quorate, int loop)
{
struct votequorum_info info;
int err;
- char quorum_type[256];
+ char quorumtype[256];
+
+ memset(quorumtype, 0, sizeof(quorumtype));
if (!loop) {
printf("Version: %s\n", VERSION);
- if (get_quorum_type(quorum_type, sizeof(quorum_type))) {
- strncpy(quorum_type, "Not configured", sizeof(quorum_type) - 1);
+ if (get_quorum_type(quorumtype, sizeof(quorumtype))) {
+ strncpy(quorumtype, "Not configured", sizeof(quorumtype) - 1);
}
- printf("Quorum type: %s\n", quorum_type);
+ printf("Quorum type: %s\n", quorumtype);
}
printf("Nodes: %d\n", g_view_list_entries);
--
1.7.7.6
_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss
[Corosync Project]
[Linux USB Devel]
[Video for Linux]
[Linux Audio Users]
[Photo]
[Yosemite News]
[Yosemite Photos]
[Free Online Dating]
[Linux Kernel]
[Linux SCSI]
[XFree86]