Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libxml2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
69
Issues
69
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
libxml2
Commits
a28bc751
Commit
a28bc751
authored
Sep 20, 2019
by
Nick Wellnhofer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix integer overflow in entity recursion check
parent
e91cbcf6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
parser.c
parser.c
+15
-6
No files found.
parser.c
View file @
a28bc751
...
...
@@ -140,7 +140,7 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
if
((
ent
!=
NULL
)
&&
(
ent
->
etype
!=
XML_INTERNAL_PREDEFINED_ENTITY
)
&&
(
ent
->
content
!=
NULL
)
&&
(
ent
->
checked
==
0
)
&&
(
ctxt
->
errNo
!=
XML_ERR_ENTITY_LOOP
))
{
unsigned
long
oldnbent
=
ctxt
->
nbentities
;
unsigned
long
oldnbent
=
ctxt
->
nbentities
,
diff
;
xmlChar
*
rep
;
ent
->
checked
=
1
;
...
...
@@ -153,7 +153,10 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
ent
->
content
[
0
]
=
0
;
}
ent
->
checked
=
(
ctxt
->
nbentities
-
oldnbent
+
1
)
*
2
;
diff
=
ctxt
->
nbentities
-
oldnbent
+
1
;
if
(
diff
>
INT_MAX
/
2
)
diff
=
INT_MAX
/
2
;
ent
->
checked
=
diff
*
2
;
if
(
rep
!=
NULL
)
{
if
(
xmlStrchr
(
rep
,
'<'
))
ent
->
checked
|=
1
;
...
...
@@ -3990,14 +3993,17 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
*/
if
((
ent
->
etype
!=
XML_INTERNAL_PREDEFINED_ENTITY
)
&&
(
ent
->
content
!=
NULL
)
&&
(
ent
->
checked
==
0
))
{
unsigned
long
oldnbent
=
ctxt
->
nbentities
;
unsigned
long
oldnbent
=
ctxt
->
nbentities
,
diff
;
++
ctxt
->
depth
;
rep
=
xmlStringDecodeEntities
(
ctxt
,
ent
->
content
,
XML_SUBSTITUTE_REF
,
0
,
0
,
0
);
--
ctxt
->
depth
;
ent
->
checked
=
(
ctxt
->
nbentities
-
oldnbent
+
1
)
*
2
;
diff
=
ctxt
->
nbentities
-
oldnbent
+
1
;
if
(
diff
>
INT_MAX
/
2
)
diff
=
INT_MAX
/
2
;
ent
->
checked
=
diff
*
2
;
if
(
rep
!=
NULL
)
{
if
(
xmlStrchr
(
rep
,
'<'
))
ent
->
checked
|=
1
;
...
...
@@ -7096,7 +7102,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
((
ent
->
children
==
NULL
)
&&
(
ctxt
->
options
&
XML_PARSE_NOENT
)))
&&
((
ent
->
etype
!=
XML_EXTERNAL_GENERAL_PARSED_ENTITY
)
||
(
ctxt
->
options
&
(
XML_PARSE_NOENT
|
XML_PARSE_DTDVALID
))))
{
unsigned
long
oldnbent
=
ctxt
->
nbentities
;
unsigned
long
oldnbent
=
ctxt
->
nbentities
,
diff
;
/*
* This is a bit hackish but this seems the best
...
...
@@ -7137,7 +7143,10 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
* Store the number of entities needing parsing for this entity
* content and do checkings
*/
ent
->
checked
=
(
ctxt
->
nbentities
-
oldnbent
+
1
)
*
2
;
diff
=
ctxt
->
nbentities
-
oldnbent
+
1
;
if
(
diff
>
INT_MAX
/
2
)
diff
=
INT_MAX
/
2
;
ent
->
checked
=
diff
*
2
;
if
((
ent
->
content
!=
NULL
)
&&
(
xmlStrchr
(
ent
->
content
,
'<'
)))
ent
->
checked
|=
1
;
if
(
ret
==
XML_ERR_ENTITY_LOOP
)
{
...
...
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