Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libplist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
pwn
libplist
Commits
bbd33793
Commit
bbd33793
authored
Jan 03, 2017
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xplist: Refine XML parsing error messages
parent
5b0184aa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
15 deletions
+18
-15
xplist.c
src/xplist.c
+18
-15
No files found.
src/xplist.c
View file @
bbd33793
...
...
@@ -589,14 +589,14 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_le
}
else
{
p
=
ctx
->
pos
;
find_next
(
ctx
,
"
\r\n\t
>"
,
5
,
1
);
PLIST_XML_ERR
(
"Invalid special tag
'<[%.*s>' encountered inside '<%s>'
tag
\n
"
,
(
int
)(
ctx
->
pos
-
p
),
p
,
tag
);
PLIST_XML_ERR
(
"Invalid special tag
<[%.*s> encountered inside <%s>
tag
\n
"
,
(
int
)(
ctx
->
pos
-
p
),
p
,
tag
);
ctx
->
err
++
;
return
NULL
;
}
}
else
{
p
=
ctx
->
pos
;
find_next
(
ctx
,
"
\r\n\t
>"
,
5
,
1
);
PLIST_XML_ERR
(
"Invalid special tag
'<!%.*s>' encountered inside '<%s>'
tag
\n
"
,
(
int
)(
ctx
->
pos
-
p
),
p
,
tag
);
PLIST_XML_ERR
(
"Invalid special tag
<!%.*s> encountered inside <%s>
tag
\n
"
,
(
int
)(
ctx
->
pos
-
p
),
p
,
tag
);
ctx
->
err
++
;
return
NULL
;
}
...
...
@@ -605,7 +605,7 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_le
}
else
{
p
=
ctx
->
pos
;
find_next
(
ctx
,
"
\r\n\t
>"
,
5
,
1
);
PLIST_XML_ERR
(
"Invalid tag
'<%.*s>' encountered inside '<%s>'
tag
\n
"
,
(
int
)(
ctx
->
pos
-
p
),
p
,
tag
);
PLIST_XML_ERR
(
"Invalid tag
<%.*s> encountered inside <%s>
tag
\n
"
,
(
int
)(
ctx
->
pos
-
p
),
p
,
tag
);
ctx
->
err
++
;
return
NULL
;
}
...
...
@@ -788,16 +788,16 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t
static
void
node_from_xml
(
parse_ctx
ctx
,
plist_t
*
plist
,
uint32_t
depth
)
{
char
*
keyname
=
NULL
;
const
char
*
p
=
NULL
;
while
(
ctx
->
pos
<
ctx
->
end
&&
!
ctx
->
err
)
{
#ifdef DEBUG
const
char
*
start
=
ctx
->
pos
;
#endif
parse_skip_ws
(
ctx
);
if
(
ctx
->
pos
>=
ctx
->
end
)
{
break
;
}
if
(
*
ctx
->
pos
!=
'<'
)
{
PLIST_XML_ERR
(
"Failed to parse XML. Expected: opening tag, found: '%s', pos: %s
\n
"
,
start
,
ctx
->
pos
);
p
=
ctx
->
pos
;
find_next
(
ctx
,
"
\t\r\n
"
,
4
,
0
);
PLIST_XML_ERR
(
"Expected: opening tag, found: %.*s
\n
"
,
(
int
)(
ctx
->
pos
-
p
),
p
);
ctx
->
pos
=
ctx
->
end
;
ctx
->
err
++
;
break
;
...
...
@@ -856,14 +856,16 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
ctx
->
pos
+=
2
;
}
}
else
{
PLIST_XML_ERR
(
"Unknown ! special tag encountered
\n
"
);
p
=
ctx
->
pos
;
find_next
(
ctx
,
"
\r\n\t
>"
,
5
,
1
);
PLIST_XML_ERR
(
"Invalid special tag <%.*s> encountered
\n
"
,
(
int
)(
ctx
->
pos
-
p
),
p
);
ctx
->
err
++
;
}
continue
;
}
else
{
int
is_empty
=
0
;
int
closing_tag
=
0
;
const
char
*
p
=
ctx
->
pos
;
p
=
ctx
->
pos
;
find_next
(
ctx
,
"
\r\n\t
<>"
,
6
,
0
);
if
(
ctx
->
pos
>=
ctx
->
end
)
{
PLIST_XML_ERR
(
"Unexpected EOF while parsing XML
\n
"
);
...
...
@@ -888,7 +890,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
return
;
}
if
(
*
ctx
->
pos
!=
'>'
)
{
PLIST_XML_ERR
(
"Missing '>' for tag
'%s'
\n
"
,
tag
);
PLIST_XML_ERR
(
"Missing '>' for tag
<%s
\n
"
,
tag
);
ctx
->
pos
=
ctx
->
end
;
ctx
->
err
++
;
free
(
tag
);
...
...
@@ -905,6 +907,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
if
(
!
strcmp
(
tag
,
"plist"
))
{
free
(
tag
);
if
(
is_empty
)
{
PLIST_XML_ERR
(
"Empty plist tag
\n
"
);
return
;
}
if
(
!*
plist
)
{
...
...
@@ -920,7 +923,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
free
(
keyname
);
return
;
}
else
if
(
depth
==
1
&&
*
plist
)
{
PLIST_XML_ERR
(
"Unexpected tag
%s found while /plist
is expected
\n
"
,
tag
);
PLIST_XML_ERR
(
"Unexpected tag
<%s> found while </plist>
is expected
\n
"
,
tag
);
ctx
->
err
++
;
free
(
tag
);
free
(
keyname
);
...
...
@@ -1151,7 +1154,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
}
else
if
(
tag
[
0
]
==
'/'
)
{
closing_tag
=
1
;
}
else
{
PLIST_XML_ERR
(
"Unexpected tag
'<%s%s>' encountered while parsing XML
\n
"
,
tag
,
(
is_empty
)
?
"/"
:
""
);
PLIST_XML_ERR
(
"Unexpected tag
<%s%s> encountered
\n
"
,
tag
,
(
is_empty
)
?
"/"
:
""
);
ctx
->
pos
=
ctx
->
end
;
ctx
->
err
++
;
free
(
tag
);
...
...
@@ -1219,13 +1222,13 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
PLIST_XML_ERR
(
"missing value node in dict
\n
"
);
ctx
->
err
++
;
}
else
if
(
strcmp
(
tag
+
1
,
XPLIST_DICT
)
!=
0
)
{
PLIST_XML_ERR
(
"closing tag mismatch, expected:
/%s found: %s
\n
"
,
XPLIST_DICT
,
tag
);
PLIST_XML_ERR
(
"closing tag mismatch, expected:
</%s> found: <%s>
\n
"
,
XPLIST_DICT
,
tag
);
ctx
->
err
++
;
}
break
;
case
PLIST_ARRAY
:
if
(
strcmp
(
tag
+
1
,
XPLIST_ARRAY
)
!=
0
)
{
PLIST_XML_ERR
(
"closing tag mismatch, expected:
/%s found: %s
\n
"
,
XPLIST_ARRAY
,
tag
);
PLIST_XML_ERR
(
"closing tag mismatch, expected:
</%s> found: <%s>
\n
"
,
XPLIST_ARRAY
,
tag
);
ctx
->
err
++
;
}
break
;
...
...
@@ -1246,7 +1249,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
}
}
if
(
depth
==
1
)
{
PLIST_XML_ERR
(
"EOF while
/plist
tag is expected
\n
"
);
PLIST_XML_ERR
(
"EOF while
</plist>
tag is expected
\n
"
);
ctx
->
err
++
;
}
if
(
ctx
->
err
)
{
...
...
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