eProsima / Fast-CDR

eProsima FastCDR library provides two serialization mechanisms. One is the standard CDR serialization mechanism, while the other is a faster implementation of it. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
145 stars 103 forks source link

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

Closed MiguelCompany closed 1 week ago

MiguelCompany commented 2 weeks ago

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

Reviewer Checklist

Mario-DL commented 1 week ago

Should be also make the changes when serializing a wstring ?

MiguelCompany commented 1 week ago

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 commented 1 week ago

@Mergifyio backport 2.1.x

mergify[bot] commented 1 week ago

backport 2.1.x

✅ Backports have been created

* [#246 [21362] Fail when trying to serialize `std::string` with null characters on its content (backport #245)](https://github.com/eProsima/Fast-CDR/pull/246) has been created for branch `2.1.x`