Browse Source

Check regcomp() result. Fix konfd segmantation when illegal pattern is given.

git-svn-id: https://klish.googlecode.com/svn/trunk@458 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
625ba06faf
3 changed files with 191 additions and 226 deletions
  1. 4 1
      clish/nspace/nspace.c
  2. 183 223
      configure
  3. 4 2
      konf/tree/tree.c

+ 4 - 1
clish/nspace/nspace.c

@@ -278,9 +278,12 @@ clish_view_t *clish_nspace__get_view(const clish_nspace_t * this)
 /*--------------------------------------------------------- */
 void clish_nspace__set_prefix(clish_nspace_t * this, const char *prefix)
 {
+	int res = 0;
+
 	assert(!this->prefix);
+	res = regcomp(&this->prefix_regex, prefix, REG_EXTENDED | REG_ICASE);
+	assert(!res);
 	this->prefix = lub_string_dup(prefix);
-	regcomp(&this->prefix_regex, prefix, REG_EXTENDED | REG_ICASE);
 }
 
 /*--------------------------------------------------------- */

File diff suppressed because it is too large
+ 183 - 223
configure


+ 4 - 2
konf/tree/tree.c

@@ -135,7 +135,8 @@ void konf_tree_fprintf(konf_tree_t * this, FILE * stream,
 
 	/* regexp compilation */
 	if (pattern)
-		regcomp(&regexp, pattern, REG_EXTENDED | REG_ICASE);
+		if (regcomp(&regexp, pattern, REG_EXTENDED | REG_ICASE) != 0)
+			return;
 
 	/* iterate child elements */
 	for(iter = lub_list__get_head(this->list);
@@ -277,7 +278,8 @@ int konf_tree_del_pattern(konf_tree_t *this,
 		return 0;
 
 	/* Compile regular expression */
-	regcomp(&regexp, pattern, REG_EXTENDED | REG_ICASE);
+	if (regcomp(&regexp, pattern, REG_EXTENDED | REG_ICASE) != 0)
+		return -1;
 
 	/* Iterate configuration tree */
 	tmp = lub_list_node_new(NULL);

Some files were not shown because too many files changed in this diff