소스 검색

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 년 전
부모
커밋
625ba06faf
3개의 변경된 파일191개의 추가작업 그리고 226개의 파일을 삭제
  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);
 }
 
 /*--------------------------------------------------------- */

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 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);

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.