소스 검색

coroparse: Ensure that config items fits into cmap

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Jan Friesse 12 년 전
부모
커밋
675da75759
1개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      exec/coroparse.c

+ 8 - 0
exec/coroparse.c

@@ -330,6 +330,10 @@ static int parse_section(FILE *fp,
 			loc--;
 			loc--;
 			*loc = '\0';
 			*loc = '\0';
 
 
+			if (strlen(path) + strlen(section) + 1 >= ICMAP_KEYNAME_MAXLEN) {
+				*error_string = "parser error: Start of section makes total cmap path too long";
+				return -1;
+			}
 			strcpy(new_keyname, path);
 			strcpy(new_keyname, path);
 			if (strcmp(path, "") != 0) {
 			if (strcmp(path, "") != 0) {
 				strcat(new_keyname, ".");
 				strcat(new_keyname, ".");
@@ -355,6 +359,10 @@ static int parse_section(FILE *fp,
 			key = remove_whitespace(line, 1);
 			key = remove_whitespace(line, 1);
 			value = remove_whitespace(loc, 0);
 			value = remove_whitespace(loc, 0);
 
 
+			if (strlen(path) + strlen(key) + 1 >= ICMAP_KEYNAME_MAXLEN) {
+				*error_string = "parser error: New key makes total cmap path too long";
+				return -1;
+			}
 			strcpy(new_keyname, path);
 			strcpy(new_keyname, path);
 			if (strcmp(path, "") != 0) {
 			if (strcmp(path, "") != 0) {
 				strcat(new_keyname, ".");
 				strcat(new_keyname, ".");