summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/aws-c-common/source/xml_parser.c
diff options
context:
space:
mode:
authorrobot-contrib <[email protected]>2025-05-14 14:52:53 +0300
committerrobot-contrib <[email protected]>2025-05-14 15:07:43 +0300
commitd66298dbca4fcd6219a910c0b9498142439950c6 (patch)
tree83a8b21d47a162936045e44ded53422a2987de4b /contrib/restricted/aws/aws-c-common/source/xml_parser.c
parent0b8daea4ea00e541685569c84670115ed35ed8ac (diff)
Update contrib/restricted/aws/aws-c-common to 0.12.3
commit_hash:f3f79235feeb6355ed1e2af98595118f592fab70
Diffstat (limited to 'contrib/restricted/aws/aws-c-common/source/xml_parser.c')
-rw-r--r--contrib/restricted/aws/aws-c-common/source/xml_parser.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/contrib/restricted/aws/aws-c-common/source/xml_parser.c b/contrib/restricted/aws/aws-c-common/source/xml_parser.c
index 7675bff3017..c6141822cc9 100644
--- a/contrib/restricted/aws/aws-c-common/source/xml_parser.c
+++ b/contrib/restricted/aws/aws-c-common/source/xml_parser.c
@@ -127,6 +127,12 @@ int aws_xml_parse(struct aws_allocator *allocator, const struct aws_xml_parser_o
goto clean_up;
}
+ if (start > location) {
+ AWS_LOGF_ERROR(AWS_LS_COMMON_XML_PARSER, "XML document is invalid.");
+ parser.error = aws_raise_error(AWS_ERROR_INVALID_XML);
+ goto clean_up;
+ }
+
aws_byte_cursor_advance(&parser.doc, start - parser.doc.ptr);
/* if these are preamble statements, burn them. otherwise don't seek at all
* and assume it's just the doc with no preamble statements. */
@@ -227,6 +233,7 @@ int s_advance_to_closing_tag(
}
}
size_t skip_len = close_find_result.ptr - parser->doc.ptr;
+
aws_byte_cursor_advance(&parser->doc, skip_len + closing_cmp_buf.len);
depth_count--;
break;
@@ -288,7 +295,7 @@ int aws_xml_node_traverse(
const uint8_t *end_location = memchr(parser->doc.ptr, '>', parser->doc.len);
- if (!end_location) {
+ if (!end_location || next_location >= end_location) {
AWS_LOGF_ERROR(AWS_LS_COMMON_XML_PARSER, "XML document is invalid.");
aws_raise_error(AWS_ERROR_INVALID_XML);
goto error;
@@ -301,7 +308,6 @@ int aws_xml_node_traverse(
}
size_t node_name_len = end_location - next_location;
-
aws_byte_cursor_advance(&parser->doc, end_location - parser->doc.ptr + 1);
if (parent_closed) {
@@ -368,13 +374,14 @@ int s_node_next_sibling(struct aws_xml_parser *parser) {
const uint8_t *next_location = memchr(parser->doc.ptr, '<', parser->doc.len);
if (!next_location) {
- return parser->error;
+ AWS_LOGF_ERROR(AWS_LS_COMMON_XML_PARSER, "XML document is invalid.");
+ return aws_raise_error(AWS_ERROR_INVALID_XML);
}
aws_byte_cursor_advance(&parser->doc, next_location - parser->doc.ptr);
const uint8_t *end_location = memchr(parser->doc.ptr, '>', parser->doc.len);
- if (!end_location) {
+ if (!end_location || next_location >= end_location) {
AWS_LOGF_ERROR(AWS_LS_COMMON_XML_PARSER, "XML document is invalid.");
return aws_raise_error(AWS_ERROR_INVALID_XML);
}