Commit da70156e by Nelson Elhage Committed by Patrick Steinhardt

config: convert unbounded recursion into a loop

(cherry picked from commit a03113e8)
parent e98d0a37
......@@ -1349,8 +1349,9 @@ static int parse_multiline_variable(struct reader *reader, git_buf *value, int i
{
char *line = NULL, *proc_line = NULL;
int quote_count;
bool multiline;
bool multiline = true;
while (multiline) {
/* Check that the next line exists */
line = reader_readline(reader, false);
if (line == NULL)
......@@ -1368,9 +1369,8 @@ static int parse_multiline_variable(struct reader *reader, git_buf *value, int i
/* If it was just a comment, pretend it didn't exist */
if (line[0] == '\0') {
git__free(line);
return parse_multiline_variable(reader, value, quote_count);
/* TODO: unbounded recursion. This **could** be exploitable */
in_quotes = quote_count;
continue;
}
if (unescape_line(&proc_line, &multiline, line, in_quotes) < 0) {
......@@ -1383,12 +1383,8 @@ static int parse_multiline_variable(struct reader *reader, git_buf *value, int i
git__free(line);
git__free(proc_line);
/*
* If we need to continue reading the next line, let's just
* keep putting stuff in the buffer
*/
if (multiline)
return parse_multiline_variable(reader, value, quote_count);
in_quotes = quote_count;
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment