Skip to content

[21362] Fail when trying to serialize std::string with null characters on its content#245

Merged
MiguelCompany merged 6 commits intomasterfrom
hotfix/21362
Nov 8, 2024
Merged

[21362] Fail when trying to serialize std::string with null characters on its content#245
MiguelCompany merged 6 commits intomasterfrom
hotfix/21362

Conversation

@MiguelCompany
Copy link
Copy Markdown
Member

@MiguelCompany MiguelCompany commented Nov 4, 2024

Description

This addresses #69 and #214 by explicitly failing to serialize a string that contains null characters, instead of silently discard the last part of the string.

@Mergifyio backport 2.1.x 1.0.x
Note: I'm not sure whether we should backport this to 1.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
  • Any new/modified methods have been properly documented using Doxygen.
  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • Changes are API compatible.
  • N/A New feature has been added to the versions.md file (if applicable).
  • 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: CI pass and failing tests are unrelated with the changes.

Signed-off-by: Miguel Company <[email protected]>
Signed-off-by: Miguel Company <[email protected]>
@MiguelCompany MiguelCompany requested review from richiprosima and removed request for richiprosima November 5, 2024 11:20
Signed-off-by: Miguel Company <[email protected]>
@MiguelCompany MiguelCompany requested review from richiprosima and removed request for richiprosima November 5, 2024 12:05
@MiguelCompany MiguelCompany changed the title [21362] Fail when trying to serialize std::string with null characters on its content [22071] Fail when trying to serialize std::string with null characters on its content Nov 6, 2024
@MiguelCompany MiguelCompany added this to the v2.2.6 milestone Nov 6, 2024
@MiguelCompany MiguelCompany marked this pull request as ready for review November 6, 2024 11:00
@MiguelCompany MiguelCompany requested review from richiprosima and removed request for richiprosima November 6, 2024 11:00
@MiguelCompany MiguelCompany changed the title [22071] Fail when trying to serialize std::string with null characters on its content [21362] Fail when trying to serialize std::string with null characters on its content Nov 6, 2024
@MiguelCompany MiguelCompany added needs-review Mark this PR as ready to be reviewed and removed ci-pending labels Nov 6, 2024
Comment thread src/cpp/Cdr.cpp Outdated
@Mario-DL
Copy link
Copy Markdown
Contributor

Mario-DL commented Nov 8, 2024

Should be also make the changes when serializing a wstring ?

Signed-off-by: Miguel Company <[email protected]>

Co-authored-by: Mario Domínguez López <[email protected]>
@MiguelCompany
Copy link
Copy Markdown
Member Author

Should be also make the changes when serializing a wstring ?

Not sure, the standard says that for strings, the terminating null character is not transmitted. Not sure if that implies that the string can have null characters in the middle. I'd say we can handle that on a different PR

@MiguelCompany MiguelCompany requested review from Mario-DL and removed request for richiprosima November 8, 2024 08:51
Copy link
Copy Markdown
Contributor

@Mario-DL Mario-DL left a comment

Choose a reason for hiding this comment

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

LGTM

@MiguelCompany
Copy link
Copy Markdown
Member Author

@Mergifyio backport 2.1.x

@mergify
Copy link
Copy Markdown

mergify Bot commented Nov 8, 2024

backport 2.1.x

✅ Backports have been created

Details

@MiguelCompany MiguelCompany merged commit 5cc8c55 into master Nov 8, 2024
@MiguelCompany MiguelCompany deleted the hotfix/21362 branch November 8, 2024 09:06
mergify Bot pushed a commit that referenced this pull request Nov 8, 2024
…ts content (#245)

* Refs #21362. Add test.

Signed-off-by: Miguel Company <[email protected]>

* Refs #21362. Fix Cdr behavior.

Signed-off-by: Miguel Company <[email protected]>

* Refs #21362. Fix FastCDR behavior.

Signed-off-by: Miguel Company <[email protected]>

* Refs #21362. Fix dll export.

Signed-off-by: Miguel Company <[email protected]>

* Refs #21362. Leave implementation in header.

Signed-off-by: Miguel Company <[email protected]>

* Refs #21362. Apply suggestion.

Signed-off-by: Miguel Company <[email protected]>

Co-authored-by: Mario Domínguez López <[email protected]>

---------

Signed-off-by: Miguel Company <[email protected]>
Co-authored-by: Mario Domínguez López <[email protected]>
(cherry picked from commit 5cc8c55)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-pending needs-review Mark this PR as ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants