Endianness check/bit shifting needed for UCS-2 write operation in versions 4.x+ #3409
Labels
i18n-api
Issues and PRs related to the i18n implementation.
string_decoder
Issues and PRs related to the string_decoder subsystem.
The UCS-2 write operation in versions 4.x of Node does not check the endianness of the system when writing strings to memory, instead assuming little endianness for all operations. As a result, running a UCS-2 write operation on a big endian machine will result in a read operation conducted on this string returning a different string than the one originally written.
An endianness check was included in v0.12, but later removed for versions 4.x. To correct this issue, it is necessary to re-introduce this endianness check to the write operation and flip the bits of the string if the system architecture is big-endian.
For an example fix, see https://github.com/nodejs/node/blob/v0.12.7-release/src/string_bytes.cc, lines 753-777.
Pull request to resolve: #3410
The text was updated successfully, but these errors were encountered: