Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
080c52e8
Commit
080c52e8
authored
5 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup and fix potential buffer overflow in LLXMLNode from usage of memcmp instead of strncmp
parent
3f3abeaa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llxml/llxmlnode.cpp
+19
-18
19 additions, 18 deletions
indra/llxml/llxmlnode.cpp
with
19 additions
and
18 deletions
indra/llxml/llxmlnode.cpp
+
19
−
18
View file @
080c52e8
...
...
@@ -623,7 +623,7 @@ bool LLXMLNode::updateNode(
child
->
getAttributeString
(
"value"
,
nodeName
);
}
if
((
nodeName
!=
""
)
&&
(
updateName
==
nodeName
))
if
((
!
nodeName
.
empty
()
)
&&
(
updateName
==
nodeName
))
{
updateNode
(
child
,
updateChild
);
last_child
=
child
;
...
...
@@ -829,7 +829,7 @@ bool LLXMLNode::getLayeredXMLNode(LLXMLNodePtr& root,
{
if
(
paths
.
empty
())
return
false
;
std
::
string
filename
=
paths
.
front
();
std
::
string
const
&
filename
=
paths
.
front
();
if
(
filename
.
empty
())
{
return
false
;
...
...
@@ -919,7 +919,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const std::string& i
if
(
use_type_decorations
)
{
// ID
if
(
mID
!=
""
)
if
(
!
mID
.
empty
()
)
{
output_stream
<<
indent
<<
" id=
\"
"
<<
mID
<<
"
\"\n
"
;
}
...
...
@@ -1024,7 +1024,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const std::string& i
// erase last \n before attaching final > or />
output_stream
.
seekp
(
-
1
,
std
::
ios
::
cur
);
if
(
mChildren
.
isNull
()
&&
mValue
==
""
)
if
(
mChildren
.
isNull
()
&&
mValue
.
empty
()
)
{
output_stream
<<
" />
\n
"
;
return
;
...
...
@@ -1299,7 +1299,7 @@ BOOL LLXMLNode::getAttributeU8(const char* name, U8& value )
BOOL
LLXMLNode
::
getAttributeS8
(
const
char
*
name
,
S8
&
value
)
{
LLXMLNodePtr
node
;
S32
val
;
S32
val
=
0
;
if
(
!
(
getAttribute
(
name
,
node
)
&&
node
->
getIntValue
(
1
,
&
val
)))
{
return
false
;
...
...
@@ -1311,7 +1311,7 @@ BOOL LLXMLNode::getAttributeS8(const char* name, S8& value )
BOOL
LLXMLNode
::
getAttributeU16
(
const
char
*
name
,
U16
&
value
)
{
LLXMLNodePtr
node
;
U32
val
;
U32
val
=
0
;
if
(
!
(
getAttribute
(
name
,
node
)
&&
node
->
getUnsignedValue
(
1
,
&
val
)))
{
return
false
;
...
...
@@ -1323,7 +1323,7 @@ BOOL LLXMLNode::getAttributeU16(const char* name, U16& value )
BOOL
LLXMLNode
::
getAttributeS16
(
const
char
*
name
,
S16
&
value
)
{
LLXMLNodePtr
node
;
S32
val
;
S32
val
=
0
;
if
(
!
(
getAttribute
(
name
,
node
)
&&
node
->
getIntValue
(
1
,
&
val
)))
{
return
false
;
...
...
@@ -1542,35 +1542,35 @@ const char *LLXMLNode::parseFloat(const char *str, F64 *dest, U32 precision, Enc
{
str
=
skipWhitespace
(
str
);
if
(
mem
cmp
(
str
,
"inf"
,
3
)
==
0
)
if
(
strn
cmp
(
str
,
"inf"
,
3
)
==
0
)
{
*
(
U64
*
)
dest
=
0x7FF0000000000000ll
;
return
str
+
3
;
}
if
(
mem
cmp
(
str
,
"-inf"
,
4
)
==
0
)
if
(
strn
cmp
(
str
,
"-inf"
,
4
)
==
0
)
{
*
(
U64
*
)
dest
=
0xFFF0000000000000ll
;
return
str
+
4
;
}
if
(
mem
cmp
(
str
,
"1.#INF"
,
6
)
==
0
)
if
(
strn
cmp
(
str
,
"1.#INF"
,
6
)
==
0
)
{
*
(
U64
*
)
dest
=
0x7FF0000000000000ll
;
return
str
+
6
;
}
if
(
mem
cmp
(
str
,
"-1.#INF"
,
7
)
==
0
)
if
(
strn
cmp
(
str
,
"-1.#INF"
,
7
)
==
0
)
{
*
(
U64
*
)
dest
=
0xFFF0000000000000ll
;
return
str
+
7
;
}
F64
negative
=
1.0
f
;
F64
negative
=
1.0
;
if
(
str
[
0
]
==
'+'
)
{
++
str
;
}
if
(
str
[
0
]
==
'-'
)
{
negative
=
-
1.0
f
;
negative
=
-
1.0
;
++
str
;
}
...
...
@@ -1647,7 +1647,7 @@ const char *LLXMLNode::parseFloat(const char *str, F64 *dest, U32 precision, Enc
F64
ret
=
F64
(
int_part
)
+
(
F64
(
f_part
)
/
F64
(
1LL
<<
61
));
F64
exponent
=
1.
f
;
F64
exponent
=
1.
0
;
if
(
str
[
0
]
==
'e'
)
{
// Scientific notation!
...
...
@@ -2330,7 +2330,6 @@ void LLXMLNode::setUnsignedValue(U32 length, const U32* array, Encoding encoding
new_value
.
append
(
llformat
(
"%08X"
,
array
[
pos
]));
}
}
mValue
=
new_value
;
}
// TODO -- Handle Base32
...
...
@@ -2560,7 +2559,7 @@ void LLXMLNode::setNodeRefValue(U32 length, const LLXMLNode **array)
std
::
string
new_value
;
for
(
U32
pos
=
0
;
pos
<
length
;
++
pos
)
{
if
(
array
[
pos
]
->
mID
!=
""
)
if
(
!
array
[
pos
]
->
mID
.
empty
()
)
{
new_value
.
append
(
array
[
pos
]
->
mID
);
}
...
...
@@ -2901,7 +2900,8 @@ void LLXMLNode::createUnitTest(S32 max_num_children)
{
random_node_array
[
value
]
=
get_rand_node
(
root
);
const
char
*
node_name
=
random_node_array
[
value
]
->
mName
->
mString
;
for
(
U32
pos
=
0
;
pos
<
strlen
(
node_name
);
++
pos
)
/* Flawfinder: ignore */
U32
node_name_size
=
strlen
(
node_name
);
for
(
U32
pos
=
0
;
pos
<
node_name_size
;
++
pos
)
/* Flawfinder: ignore */
{
U32
hash_contrib
=
U32
(
node_name
[
pos
])
<<
((
pos
%
4
)
*
8
);
noderef_checksum
^=
hash_contrib
;
...
...
@@ -3073,7 +3073,8 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
for
(
U32
pos
=
0
;
pos
<
node
->
mLength
;
++
pos
)
{
const
char
*
node_name
=
node_array
[
pos
]
->
mName
->
mString
;
for
(
U32
pos2
=
0
;
pos2
<
strlen
(
node_name
);
++
pos2
)
/* Flawfinder: ignore */
U32
node_name_size
=
strlen
(
node_name
);
for
(
U32
pos2
=
0
;
pos2
<
node_name_size
;
++
pos2
)
/* Flawfinder: ignore */
{
U32
hash_contrib
=
U32
(
node_name
[
pos2
])
<<
((
pos2
%
4
)
*
8
);
noderef_checksum
^=
hash_contrib
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment