Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
da70156e
Commit
da70156e
authored
Aug 25, 2018
by
Nelson Elhage
Committed by
Patrick Steinhardt
Oct 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config: convert unbounded recursion into a loop
(cherry picked from commit
a03113e8
)
parent
e98d0a37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
33 deletions
+29
-33
src/config_file.c
+29
-33
No files found.
src/config_file.c
View file @
da70156e
...
...
@@ -1349,46 +1349,42 @@ 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
)
return
-
1
;
/* We've reached the end of the file, there is no continuation.
* (this is not an error).
*/
if
(
line
[
0
]
==
'\0'
)
{
git__free
(
line
);
return
0
;
}
/* Check that the next line exists */
line
=
reader_readline
(
reader
,
false
);
if
(
line
==
NULL
)
return
-
1
;
quote_count
=
strip_comments
(
line
,
!!
in_quotes
);
/* We've reached the end of the file, there is no continuation.
* (this is not an error).
*/
if
(
line
[
0
]
==
'\0'
)
{
git__free
(
line
);
return
0
;
}
/* If it was just a comment, pretend it didn't exist */
if
(
line
[
0
]
==
'\0'
)
{
in_quotes
=
quote_count
;
continue
;
}
quote_count
=
strip_comments
(
line
,
!!
in_quotes
);
if
(
unescape_line
(
&
proc_line
,
&
multiline
,
line
,
in_quotes
)
<
0
)
{
git__free
(
line
);
return
-
1
;
}
/* add this line to the multiline var */
/* If it was just a comment, pretend it didn't exist */
if
(
line
[
0
]
==
'\0'
)
{
git_buf_puts
(
value
,
proc_line
);
git__free
(
line
);
return
parse_multiline_variable
(
reader
,
value
,
quote_count
);
/* TODO: unbounded recursion. This **could** be exploitable */
}
git__free
(
proc_line
);
if
(
unescape_line
(
&
proc_line
,
&
multiline
,
line
,
in_quotes
)
<
0
)
{
git__free
(
line
);
return
-
1
;
in_quotes
=
quote_count
;
}
/* add this line to the multiline var */
git_buf_puts
(
value
,
proc_line
);
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
);
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment