Skip to content
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

Endianness check/bit shifting needed for UCS-2 write operation in versions 4.x+ #3409

Closed
exinfinitum opened this issue Oct 16, 2015 · 1 comment
Labels
i18n-api Issues and PRs related to the i18n implementation. string_decoder Issues and PRs related to the string_decoder subsystem.

Comments

@exinfinitum
Copy link
Contributor

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

@evanlucas
Copy link
Contributor

Closing as this has landed in master. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n-api Issues and PRs related to the i18n implementation. string_decoder Issues and PRs related to the string_decoder subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants