Skip to content

Fix invalid XML Buffer Overflow Error #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 12, 2025
Merged

Fix invalid XML Buffer Overflow Error #1201

merged 6 commits into from
May 12, 2025

Conversation

waahm7
Copy link
Contributor

@waahm7 waahm7 commented May 9, 2025

Description of changes:
Our XML parser assumes that the XML provided is valid and is intended for internal use only. I have fixed buffer overflow for some cases as it's nice to fix them but there might be other issues with invalid XML.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VSCode promoted me to upgrade Gradle.

@codecov-commenter
Copy link

codecov-commenter commented May 9, 2025

Codecov Report

Attention: Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.25%. Comparing base (8c9200c) to head (764039d).

Files with missing lines Patch % Lines
source/xml_parser.c 37.50% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1201      +/-   ##
==========================================
- Coverage   84.25%   84.25%   -0.01%     
==========================================
  Files          57       57              
  Lines        5984     5989       +5     
==========================================
+ Hits         5042     5046       +4     
- Misses        942      943       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -95,6 +95,25 @@ static int s_xml_parser_child_with_text_test(struct aws_allocator *allocator, vo

AWS_TEST_CASE(xml_parser_child_with_text, s_xml_parser_child_with_text_test)

const char *malformed = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rootNode>><child1>TestBody</child1></rootNode>";

static int s_xml_parser_malformed_test(struct aws_allocator *allocator, void *ctx) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i would call out exactly what is malformed in this test, in case we want to add more malformed tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

Copy link
Contributor

@TingDaoK TingDaoK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

size_t node_name_len = end_location - next_location;

size_t node_name_len;
if (aws_sub_size_checked((size_t)end_location, (size_t)next_location, &node_name_len)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use an if check against the pointer, which will be safer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

@waahm7 waahm7 enabled auto-merge (squash) May 9, 2025 22:30
@waahm7 waahm7 disabled auto-merge May 9, 2025 22:30
@waahm7 waahm7 merged commit aaa2f11 into main May 12, 2025
56 checks passed
@waahm7 waahm7 deleted the fix-xml-parser branch May 12, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants