Skip to content

Commit 049965b

Browse files
committed
fix issue in XML parser
1 parent c54a2f4 commit 049965b

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
2.0.12
22

3+
* fix issue in XML parser
34
* when building against OpenSSL, require at least version 1.1.1
45
* add setting to set no-copy-on-write flag on new files
56
* add performance counters to file pool

src/xml_parse.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ namespace libtorrent {
106106
}
107107
else if (*start == '?' && *(p - 1) == '?')
108108
{
109+
if (start == p - 1)
110+
{
111+
callback(xml_parse_error, "invalid declaration tag", {});
112+
break;
113+
}
109114
++start;
110115
callback(xml_declaration_tag, {start, std::size_t(std::min(tag_name_end - start, p - start - 1))}, {});
111116
tag_end = p - 1;

test/test_xml.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,7 @@ TORRENT_TEST(unterminated_tag_with_attribute)
491491
test_parse("<foo a=\"bar", "Punexpected end of file");
492492
}
493493

494+
TORRENT_TEST(invalid_declaration)
495+
{
496+
test_parse("<?>", "Pinvalid declaration tag");
497+
}

0 commit comments

Comments
 (0)