Skip to contentSkip to conversation

cluster/cman/daemon cmanccs.c

Cluster-devel [email protected] 1 participant 1 message Oct 24, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rmccabe at sourceware.org 2007-10-24 05:58:07

Modified files:
cman/daemon : cmanccs.c

Log message:
Commit msg with the last commit went missing..

- Fix unsafe string handling:
- replace memset(s,c,n);sprintf(s,...); with snprintf with proper error checking
- don't overflow the stack if the cluster name specified in the env var is too long
- don't overflow the stack if the local nodename from uname(2) is too long
- don't overflow the stack if the local nodename specified in the env var is too long

- Don't leak the ccs descriptor in get_ccs_join_info() on errors
- Fix a couple of small memory leaks in error paths
- Handle OOM conditions

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.35&r2=1.36

cman/daemon/cmanccs.c +3 -1
@@ -637,6 +637,8 @@
 	/* optional security key filename */
 	if (getenv("CMAN_KEYFILE")) {
 		key_filename = strdup(getenv("CMAN_KEYFILE"));
+		if (key_filename == NULL)
+			return -ENOMEM;
 	}
 	else {
 		error = ccs_get(cd, KEY_PATH, &str);
@@ -662,13 +664,13 @@
 		error = ccs_get(cd, path, &str);
 		if (!error) {
 			int votestmp = atoi(str);
+			free(str);
 			if (votestmp < 0 || votestmp > 255) {
 				log_printf(LOG_ERR, "invalid votes value %d", votestmp);
 				write_cman_pipe("Found invalid votes for node in CCS");
 				return -EINVAL;
 			}
 			votes = votestmp;
-			free(str);
 		}
 		else {
 			votes = 1;