Skip to content

[20732] Fix some leaks in XML DynamicTypes Parser (backport #4717) - #4735

Merged
MiguelCompany merged 2 commits into
2.10.xfrom
mergify/bp/2.10.x/pr-4717
May 9, 2024
Merged

MiguelCompany merged 2 commits into
2.10.xfrom
mergify/bp/2.10.x/pr-4717

Conversation

@mergify

@mergify mergify Bot commented Apr 26, 2024

Copy link
Copy Markdown
Contributor

Description

This PR adds a regression test with the XML reported from OSS Fuzz, and performs the following two actions on every method parsing and registering a dynamic type:

#. Doing a pre-check on whether a type with the same name is already registered in the profile manager, and perform an early return in that case
#. Tell DynamicTypeBuilderFactory to delete the builder when a call to XMLProfileManager::insertDynamicTypeByName fails.

@Mergifyio backport 2.13.x 2.10.x 2.6.x

Contributor Checklist

  • Commit messages follow the project guidelines.

  • The code follows the style guidelines of this project.

  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally

  • N/A Any new/modified methods have been properly documented using Doxygen.

  • N/A Any new configuration API has an equivalent XML API (with the corresponding XSD extension)

  • Changes are ABI compatible.

  • Changes are API compatible.

  • N/A New feature has been added to the versions.md file (if applicable).

  • N/A New feature has been documented/Current behavior is correctly described in the documentation.

  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

This is an automatic backport of pull request #4717 done by [Mergify](https://mergify.com).

@mergify

mergify Bot commented Apr 26, 2024

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 8cb447b has failed:

On branch mergify/bp/2.10.x/pr-4717
Your branch is up to date with 'origin/2.10.x'.

You are currently cherry-picking commit 8cb447bb2.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   src/cpp/rtps/xmlparser/XMLDynamicParser.cpp
	modified:   src/cpp/rtps/xmlparser/XMLProfileManager.cpp
	new file:   test/unittest/xmlparser/regressions/20732_profile_bin.xml

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   include/fastrtps/xmlparser/XMLProfileManager.h
	both modified:   test/unittest/xmlparser/XMLParserTests.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify Bot added the conflicts Backport PR wich git cherry pick failed label Apr 26, 2024
@mergify mergify Bot mentioned this pull request Apr 26, 2024
11 tasks done
@MiguelCompany MiguelCompany added this to the v2.10.4 milestone Apr 26, 2024
* Refs #20732. Add regression test.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLAliasDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLBitsetDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLBitmaskDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLEnumDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLStructDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLUnionDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20372. Return error when `insertDynamicTypeByName` fails.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20372. Fail parsing for empty name attributes.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Move implementation of `DeleteInstance` to source file.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Delete registered dynamic type builders in `XMLProfileManager::DeleteInstance()`.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 8cb447b)

# Conflicts:
#	include/fastrtps/xmlparser/XMLProfileManager.h
#	test/unittest/xmlparser/XMLParserTests.cpp
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
@MiguelCompany
MiguelCompany force-pushed the mergify/bp/2.10.x/pr-4717 branch from d83b529 to c124a1a Compare May 7, 2024 12:31
@MiguelCompany MiguelCompany removed the conflicts Backport PR wich git cherry pick failed label May 7, 2024
@MiguelCompany
MiguelCompany self-requested a review May 7, 2024 12:31
@github-actions github-actions Bot added the ci-pending PR which CI is running label May 7, 2024
@MiguelCompany

Copy link
Copy Markdown
Member

@richiprosima Please test this

@MiguelCompany

Copy link
Copy Markdown
Member

@Mergifyio backport 2.6.x

@mergify

mergify Bot commented May 7, 2024 •

Copy link
Copy Markdown
Contributor Author

backport 2.6.x

โœ… Backports have been created

Details

@MiguelCompany

Copy link
Copy Markdown
Member

@richiprosima Please test mac

2 similar comments
@MiguelCompany

Copy link
Copy Markdown
Member

@richiprosima Please test mac

@MiguelCompany

Copy link
Copy Markdown
Member

@richiprosima Please test mac

@MiguelCompany

Copy link
Copy Markdown
Member

@richiprosima please test mac

@MiguelCompany

Copy link
Copy Markdown
Member

@richiprosima Please test mac

@MiguelCompany
MiguelCompany merged commit 04e90a2 into 2.10.x May 9, 2024
@MiguelCompany
MiguelCompany deleted the mergify/bp/2.10.x/pr-4717 branch May 9, 2024 12:42
mergify Bot added a commit that referenced this pull request May 9, 2024
* Fix some leaks in XML DynamicTypes Parser (#4717)

* Refs #20732. Add regression test.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLAliasDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLBitsetDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLBitmaskDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLEnumDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLStructDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLUnionDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20372. Return error when `insertDynamicTypeByName` fails.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20372. Fail parsing for empty name attributes.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Move implementation of `DeleteInstance` to source file.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Delete registered dynamic type builders in `XMLProfileManager::DeleteInstance()`.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 8cb447b)

# Conflicts:
#	include/fastrtps/xmlparser/XMLProfileManager.h
#	test/unittest/xmlparser/XMLParserTests.cpp

* Fix conflicts

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 04e90a2)
MiguelCompany added a commit that referenced this pull request May 14, 2024
* Fix some leaks in XML DynamicTypes Parser (#4717)

* Refs #20732. Add regression test.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLAliasDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLBitsetDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLBitmaskDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLEnumDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLStructDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLUnionDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20372. Return error when `insertDynamicTypeByName` fails.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20372. Fail parsing for empty name attributes.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Move implementation of `DeleteInstance` to source file.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Delete registered dynamic type builders in `XMLProfileManager::DeleteInstance()`.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 8cb447b)

# Conflicts:
#	include/fastrtps/xmlparser/XMLProfileManager.h
#	test/unittest/xmlparser/XMLParserTests.cpp

* Fix conflicts

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 04e90a2)
EduPonz pushed a commit that referenced this pull request May 20, 2024
* Fix some leaks in XML DynamicTypes Parser (#4717) (#4735)

* Fix some leaks in XML DynamicTypes Parser (#4717)

* Refs #20732. Add regression test.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLAliasDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLBitsetDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLBitmaskDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLEnumDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLStructDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Fixes on parseXMLUnionDynamicType.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20372. Return error when `insertDynamicTypeByName` fails.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20372. Fail parsing for empty name attributes.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Move implementation of `DeleteInstance` to source file.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20732. Delete registered dynamic type builders in `XMLProfileManager::DeleteInstance()`.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 8cb447b)

# Conflicts:
#	include/fastrtps/xmlparser/XMLProfileManager.h
#	test/unittest/xmlparser/XMLParserTests.cpp

* Fix conflicts

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 04e90a2)

* Use old log macros

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-pending PR which CI is running

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant