Browse code

cfg framework: crash when adding a new group instance

A log message trying to print a NULL variable name caused
a crash when a new group instance was added before forking
without any variable.

Miklos Tirpak authored on 04/01/2011 10:28:53
Showing 1 changed files
... ...
@@ -876,10 +876,19 @@ int new_add_var(str *group_name, unsigned int group_id, str *var_name,
876 876
 	cfg_add_var_t	*add_var = NULL, **add_var_p;
877 877
 	int		len;
878 878
 
879
-	LOG(L_DBG, "DEBUG: new_add_var(): declaring a new variable instance %.*s[%u].%.*s\n",
879
+	if (type && (!var_name || !val)) {
880
+		LOG(L_ERR, "ERROR: new_add_var(): Missing variable/value specification\n");
881
+		goto error;
882
+	}
883
+	if (type)
884
+		LOG(L_DBG, "DEBUG: new_add_var(): declaring a new variable instance %.*s[%u].%.*s\n",
880 885
 			group_name->len, group_name->s,
881 886
 			group_id,
882 887
 			var_name->len, var_name->s);
888
+	else
889
+		LOG(L_DBG, "DEBUG: new_add_var(): declaring a new group instance %.*s[%u]\n",
890
+			group_name->len, group_name->s,
891
+			group_id);
883 892
 
884 893
 	if (cfg_shmized) {
885 894
 		LOG(L_ERR, "ERROR: new_add_var(): too late, the configuration has already been shmized\n");