Explorar o código

coroparse: Return error if config line is too long

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse %!s(int64=7) %!d(string=hai) anos
pai
achega
20bd68b3fb
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      exec/coroparse.c

+ 9 - 0
exec/coroparse.c

@@ -304,6 +304,15 @@ static int parse_section(FILE *fp,
 
 	while (fgets (line, sizeof (line), fp)) {
 		if (strlen(line) > 0) {
+			/*
+			 * Check if complete line was read. Use feof to handle files
+			 * without ending \n at the end of the file
+			 */
+			if ((line[strlen(line) - 1] != '\n') && !feof(fp)) {
+				*error_string = "parser error: Line too long";
+				return -1;
+			}
+
 			if (line[strlen(line) - 1] == '\n')
 				line[strlen(line) - 1] = '\0';
 			if (strlen (line) > 0 && line[strlen(line) - 1] == '\r')