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

[buffer] transcode() to utf16le is broken #9834

Closed
trevnorris opened this issue Nov 29, 2016 · 1 comment
Closed

[buffer] transcode() to utf16le is broken #9834

trevnorris opened this issue Nov 29, 2016 · 1 comment
Labels
buffer Issues and PRs related to the buffer subsystem.

Comments

@trevnorris
Copy link
Contributor

  • Version: v7.2.0
  • Platform: Linux
  • Subsystem: buffer

Examples of brokenness:

// note: this works properly if `fromEnc` is 'utf8'
buffer.transcode(Buffer.from('hi', 'ascii'), 'ascii', 'utf16le')
// expect: <Buffer 68 00 69 00>
// get:    <Buffer 68 00 69 00 00 00 00 00 60 db 18 c6 fe 7f 00 00>

buffer.transcode(Buffer.from('hi', 'latin1'), 'latin1', 'utf16le')
// expect: <Buffer 68 00 69 00>
// get:    <Buffer 68 00 69 00 00 00 00 00 60 db 18 c6 fe 7f 00 00>

buffer.transcode(Buffer.from('\u00e4', 'latin1'), 'latin1', 'utf16le')
// expect: <Buffer e4 00>
// get:    <Buffer e4 00 00 00 fe 7f 00 00>

Not sure when I'll have time to look into this.

/cc @jasnell

@trevnorris trevnorris added the buffer Issues and PRs related to the buffer subsystem. label Nov 29, 2016
@trevnorris
Copy link
Contributor Author

Is this possibly happening b/c it's actually converting to UCS2 and not proper UTF16-LE?

addaleax added a commit to addaleax/node that referenced this issue Nov 29, 2016
Fix `buffer.transcode()` for transcoding from single-byte character
encodings to UCS2.

These would previously perform out-of-bounds reads due to an
incorrect `sizeof()` expression.

Fixes: nodejs#9834
addaleax added a commit that referenced this issue Dec 6, 2016
Fix `buffer.transcode()` for transcoding from single-byte character
encodings to UCS2.

These would previously perform out-of-bounds reads due to an
incorrect `sizeof()` expression.

Fixes: #9834
PR-URL: #9838
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
jmdarling pushed a commit to jmdarling/node that referenced this issue Dec 8, 2016
Fix `buffer.transcode()` for transcoding from single-byte character
encodings to UCS2.

These would previously perform out-of-bounds reads due to an
incorrect `sizeof()` expression.

Fixes: nodejs#9834
PR-URL: nodejs#9838
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem.
Projects
None yet
Development

No branches or pull requests

1 participant