FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 11-23-2011, 09:15 AM
"Fabio M. Di Nitto"
 
Default cman: fix a few var checks and types

Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 fb534a9... 9d52fde... M cman/daemon/cman-preconfig.c
:100644 100644 f23f386... d3009d0... M cman/daemon/cmanconfig.c
:100644 100644 02fe88d... 1489f7c... M cman/daemon/commands.c
:100644 100644 92cfd47... b85557d... M cman/daemon/daemon.c
cman/daemon/cman-preconfig.c | 12 +++++++++---
cman/daemon/cmanconfig.c | 2 +-
cman/daemon/commands.c | 10 ++++++++--
cman/daemon/daemon.c | 2 +-
4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index fb534a9..9d52fde 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -458,7 +458,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *node)
/* If nodename (from uname) is domain-less, try to match against
cluster.conf names which may have domainname specified */
nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &find_handle);
- do {
+ while (nodes_handle) {
int len;

if (objdb_get_string(objdb, nodes_handle, "name", &str)) {
@@ -480,7 +480,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *node)
return 0;
}
nodes_handle = nodeslist_next(objdb, find_handle);
- } while (nodes_handle);
+ }
objdb->object_find_destroy(find_handle);


@@ -706,6 +706,12 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
}
objdb->object_find_destroy(find_handle);

+ if (!nodeid_str) {
+ sprintf(error_reason, "This node has no nodeid in cluster.conf");
+ write_cman_pipe("This node has no nodeid in cluster.conf");
+ return -1;
+ }
+
nodeid = atoi(nodeid_str);
error = 0;

@@ -1024,7 +1030,7 @@ static void add_cman_overrides(struct objdb_iface_ver0 *objdb)
int keylen;
memset(tmp, 0, sizeof(tmp));

- strcpy(tmp, cluster_name);
+ strncpy(tmp, cluster_name, sizeof(tmp) - 1);

/* Key length must be a multiple of 4 */
keylen = (strlen(cluster_name)+4) & 0xFC;
diff --git a/cman/daemon/cmanconfig.c b/cman/daemon/cmanconfig.c
index f23f386..d3009d0 100644
--- a/cman/daemon/cmanconfig.c
+++ b/cman/daemon/cmanconfig.c
@@ -238,7 +238,7 @@ static int get_cman_join_info(struct corosync_api_v1 *corosync)
if (!votes) {
unsigned int votestmp=-1;
objdb_get_int(corosync, node_object, "votes", &votestmp, 1);
- if (votestmp < 0 || votestmp > 255) {
+ if (votestmp > 255) {
log_printf(LOG_ERR, "invalid votes value %d", votestmp);
write_cman_pipe("Found invalid votes for node in CCS");
return -EINVAL;
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index 02fe88d..1489f7c 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -457,8 +457,10 @@ int cman_join_cluster(struct corosync_api_v1 *api,
/* Make sure we have a node name */
if (nodename[0] == '') {
struct utsname un;
- uname(&un);
- strcpy(nodename, un.nodename);
+ if (uname(&un)) {
+ return -EINVAL;
+ }
+ strncpy(nodename, un.nodename, sizeof(nodename) - 1);
}

time(&join_time);
@@ -2314,6 +2316,10 @@ void add_ais_node(int nodeid, uint64_t incar, int total_members)
/* Emergency nodename */
sprintf(tempname, "Node%d", nodeid);
node = add_new_node(tempname, nodeid, 1, total_members, NODESTATE_DEAD);
+ if (!node) {
+ log_printf(LOG_ERR, "Unable to add newnode!
");
+ return;
+ }
}

if (node->state == NODESTATE_DEAD || node->state == NODESTATE_LEAVING) {
diff --git a/cman/daemon/daemon.c b/cman/daemon/daemon.c
index 92cfd47..b85557d 100644
--- a/cman/daemon/daemon.c
+++ b/cman/daemon/daemon.c
@@ -353,7 +353,7 @@ static int process_rendezvous(hdb_handle_t handle, int fd, int revent, void *dat
return 0;
}

-static int open_local_sock(const char *name, int name_len, mode_t mode, hdb_handle_t handle, int type)
+static int open_local_sock(const char *name, int name_len, mode_t mode, hdb_handle_t handle, con_type_t type)
{
int local_socket;
struct sockaddr_un sockaddr;
--
1.7.4.4
 

Thread Tools




All times are GMT. The time now is 02:35 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org