Mert Can Altin
28979fb595
src: use simdutf for one-byte string UTF-8 write in stringBytes
...
PR-URL: https://github.com/nodejs/node/pull/61696
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Daniel Lemire <daniel@lemire.me >
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br >
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com >
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
2026-02-07 21:04:29 +01:00
Nikita Skovoroda and Gürgün Dayıoğlu
77e8d443ac
src: improve StringBytes::Encode perf on UTF8
...
Co-authored-by: Gürgün Dayıoğlu <hey@gurgun.day >
PR-URL: https://github.com/nodejs/node/pull/61131
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Daniel Lemire <daniel@lemire.me >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2026-01-21 18:40:17 +00:00
Nikita Skovoroda
36ffbc5357
src: improve StringBytes::Encode perf on ASCII
...
PR-URL: https://github.com/nodejs/node/pull/61119
Reviewed-By: Daniel Lemire <daniel@lemire.me >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day >
Reviewed-By: Xuguang Mei <meixuguang@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2025-12-27 00:04:17 +00:00
Anna Henningsen
39447be4e4
src: use Utf8Value and TwoByteValue instead of V8 helpers
...
Our own helper classes have the advantage of using stack storage
a lot of the time, so they should always be preferred.
PR-URL: https://github.com/nodejs/node/pull/60244
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Ilyas Shabi <ilyasshabi94@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com >
2025-10-17 09:17:01 +00:00
Chengzhong Wu
5af035503a
src: migrate WriteOneByte to WriteOneByteV2
...
PR-URL: https://github.com/nodejs/node/pull/59634
Fixes: https://github.com/nodejs/node/issues/59555
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-08-29 22:41:00 +00:00
Tobias Nießen
e38ce27f3c
src: refactor WriteUCS2 and remove flags argument
...
This change refactors `StringBytes::WriteUCS2()` in multiple ways.
The `flags` argument being passed to `WriteUCS2()` is not useful: the
only really relevant flag is `NO_NULL_TERMINATION` since V8 ignores
`REPLACE_INVALID_UTF8`, `HINT_MANY_WRITES_EXPECTED`, and
`PRESERVE_ONE_BYTE_NULL` for UTF-16 strings. However, `WriteUCS2()`
might not null-terminate the result correctly regardless of whether
`NO_NULL_TERMINATION` is set because it makes multiple calls to
`String::Write()` internally. For these reasons, this patch removes the
`flags` argument entirely and always assumes `NO_NULL_TERMINATION`.
Next, this patch replaces the calls to the deprecated function
`String::Write()` with calls to the new function `String::WriteV2()`,
which always succeeds and always writes a predictable number of
characters, removing the need to deal with a return value here.
Lastly, this patch simplifies the implementation of `WriteUCS2()` and
computes the exact number of characters `nchars` from the beginning,
removing the need to later check again if the number of characters is
zero.
PR-URL: https://github.com/nodejs/node/pull/58163
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-05-08 12:55:26 +00:00
Yagiz Nizipli
3ec86eb028
src: use non-deprecated WriteUtf8V2() method
...
PR-URL: https://github.com/nodejs/node/pull/58070
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-05-02 15:10:39 +02:00
Michaël Zasso
742c0eb126
src: use v8::ExternalMemoryAccounter
...
`Isolate::AdjustAmountOfExternalAllocatedMemory` is deprecated.
Refs: https://github.com/v8/v8/commit/7dc4c181956be958e98ecd6bfe7ec636b4b23c62
PR-URL: https://github.com/nodejs/node/pull/58070
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-05-02 15:10:37 +02:00
James M Snell
93644d5126
src: improve StringBytes error handling
...
PR-URL: https://github.com/nodejs/node/pull/57706
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-04-06 17:19:44 +00:00
zhenweijin
1ba47324e0
buffer: make buflen in integer range
...
PR-URL: https://github.com/nodejs/node/pull/51821
Fixes: https://github.com/nodejs/node/issues/51817
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-03-14 10:44:25 -07:00
James M Snell
cbedcd1696
src: improve error handling in string_bytes/decoder
...
PR-URL: https://github.com/nodejs/node/pull/56978
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-02-11 16:40:02 +00:00
Michaël Zasso
9f2885ad21
Revert "src: migrate String::Value to String::ValueView"
...
This reverts commit 45c6a9e1f6 .
PR-URL: https://github.com/nodejs/node/pull/55828
Fixes: https://github.com/nodejs/node/issues/55826
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Jason Zhang <xzha4350@gmail.com >
2024-11-16 23:42:26 +00:00
Aviv Keller
45c6a9e1f6
src: migrate String::Value to String::ValueView
...
Fixes #54417
Ref: #55452
PR-URL: https://github.com/nodejs/node/pull/55458
Refs: https://github.com/nodejs/node/issues/55452
Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2024-10-29 00:32:26 +00:00
Yagiz Nizipli
8191e1f575
src: improve utf8 string generation performance
...
PR-URL: https://github.com/nodejs/node/pull/54873
Reviewed-By: Daniel Lemire <daniel@lemire.me >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2024-09-17 00:19:46 +00:00
Daniel Lemire
9f5977fdac
src: simplify string_bytes with views
...
PR-URL: https://github.com/nodejs/node/pull/54876
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2024-09-12 16:07:08 +00:00
James M Snell
d335487e3f
src, deps: add nbytes library
...
Projects that seek to implement Node.js compatible APIs end up
needed to reproduce various bits of functionality internally in
order to faithfully replicate the Node.js behaviors. This is
particularly true for things like byte manipulation, base64 and
hex encoding, and other low-level operations. This change
proposes moving much of this low-level byte manipulation code
out of nodejs/src and into a new `nbytes` library. Initially this
new library will exist in the `deps` directory but the intent is
to spin out a new separate repository to be its home in the future.
Doing so will allow other projects to use the nbytes library with
exactly the same implementation as Node.js.
This commit moves only the byte swapping and legacy base64 handling
code. Additional commits will move additional byte manipulation
logic into the library.
PR-URL: https://github.com/nodejs/node/pull/53507
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2024-06-21 07:38:37 -07:00
Tobias Nießen
177b8b957b
src: convert all endian checks to constexpr
...
This is finally possible in C++20 without having to rely on
compiler-defined macros, assuming none of our supported platforms are
mixed-endian.
Refs: https://github.com/nodejs/node/pull/44411
PR-URL: https://github.com/nodejs/node/pull/52974
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: James M Snell <jasnell@gmail.com >
2024-05-25 09:04:20 +00:00
Xavier Stouder
05a941f3f2
buffer: use size_t instead of uint32_t to avoid segmentation fault
...
Fixes: https://github.com/nodejs/node/issues/46836
PR-URL: https://github.com/nodejs/node/pull/48033
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2024-05-11 15:27:03 +02:00
Yagiz Nizipli and Daniel Lemire
422163174c
buffer: improve base64 and base64url performance
...
Co-authored-by: Daniel Lemire <daniel@lemire.me >
PR-URL: https://github.com/nodejs/node/pull/52428
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2024-04-12 02:50:25 +00:00
Mohammed Keyvanzadeh
dd6eb67b1f
src: prefer data accessor of string and vector
...
The pattern of getting the address of the element at index 0 of a
container is generally used to materialize a pointer to the backing
data of a container, however `std::string` and `std::vector`
provide a `data()` accessor to retrieve the data pointer which
should be preferred.
This also ensures that in the case that the container is empty, the
data pointer access does not perform an errant memory access.
PR-URL: https://github.com/nodejs/node/pull/47750
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-05-03 14:09:23 +00:00
Tobias Nießen
f0e645321c
src: use UNREACHABLE instead of CHECK(falsy)
...
Also remove some dead code following such statements.
PR-URL: https://github.com/nodejs/node/pull/46317
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
2023-01-25 14:00:21 +00:00
Tobias Nießen
8c308ab28c
src: remove unreachable UNREACHABLE
...
All paths leading up to this UNREACHABLE either return or abort. (If
they did not, the compiler would at least emit a warning.)
PR-URL: https://github.com/nodejs/node/pull/46281
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2023-01-22 00:28:16 +00:00
Anna Henningsen
691314083b
src: replace custom ASCII validation with simdutf one
...
PR-URL: https://github.com/nodejs/node/pull/46271
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2023-01-21 12:53:35 +00:00
Tobias Nießen
1af661908f
src: remove UncheckedMalloc(0) workaround
...
Assuming that UncheckedMalloc(0) returns a non-nullptr is non-standard
and we use other allocators as well (e.g., OPENSSL_malloc) that do not
guarantee this behavior. It is the caller's responsibility to check that
size != 0 implies UncheckedMalloc(size) != nullptr, and that's exactly
what the checked variants (Malloc etc.) already do.
The current behavior is also inconsistent with UncheckedRealloc(), which
always returns a nullptr when the size is 0, and with the documentation
in src/README.md as well as with multiple comments in the source code.
This changes UncheckedMalloc(), UncheckedCalloc(), and
UncheckedRealloc() to always return a nullptr when the size is 0 instead
of doing fake allocations in UncheckedMalloc() and UncheckedCalloc()
while returning a nullptr from UncheckedRealloc(). This is consistent
with existing documentation and comments.
Refs: https://github.com/nodejs/node/issues/8571
Refs: https://github.com/nodejs/node/pull/8572
PR-URL: https://github.com/nodejs/node/pull/44543
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-10-05 15:39:27 +00:00
Keyhan Vakil
6e418ff94f
src,buffer: remove unused chars_written parameter
...
This parameter was always being set to `nullptr` by its callers, either
explicitly or implicitly via the default argument. It was also buggy, as
in some cases it wouldn't be written to, potentially leaking stack
memory (see the early returns in `StringBytes::WriteUCS2`). Remove it
entirely.
PR-URL: https://github.com/nodejs/node/pull/44092
Reviewed-By: Feng Yu <F3n67u@outlook.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2022-08-04 02:18:38 +00:00
Tobias Nießen
da7916676b
src: remove redundant buffer size check
...
This condition is already checked by the CHECK_BUFLEN_IN_RANGE macro,
so if it was true here, that would contradict the previous check.
PR-URL: https://github.com/nodejs/node/pull/42257
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Mestery <mestery@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-03-10 23:48:01 +00:00
Michaël Zasso
d1f1fcfe0c
src: avoid implicit type conversions (take 2)
...
This fixes more C4244 MSVC warnings in the code base.
Refs: https://github.com/nodejs/node/pull/37149
PR-URL: https://github.com/nodejs/node/pull/37334
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-20 10:50:28 +01:00
James M Snell
dae283d96f
crypto: refactoring internals, add WebCrypto
...
Fixes: https://github.com/nodejs/node/issues/678
Refs: https://github.com/nodejs/node/issues/26854
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/35093
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-10-07 17:27:05 -07:00
Anna Henningsen
fdf0a84e82
src: move all base64.h inline methods into -inl.h header file
...
Refs: https://github.com/nodejs/node/pull/34944#discussion_r480321239
PR-URL: https://github.com/nodejs/node/pull/35432
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-10-03 15:41:30 +00:00
Anna Henningsen
2899588f28
src: simplify alignment-handling code
...
Use a common function to handle alignment computations in
multiple places.
PR-URL: https://github.com/nodejs/node/pull/33884
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2020-06-19 17:34:20 +02:00
Daniel Bevenius
74d80115b6
src: remove unused vector include in string_bytes
...
PR-URL: https://github.com/nodejs/node/pull/33824
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
2020-06-15 05:52:52 +02:00
Daniel Bevenius
8f7211a60a
src: avoid unnecessary ToLocalChecked calls
...
This commit removes two unnecessary ToLocalChecked calls in
StringBytes::Encode.
PR-URL: https://github.com/nodejs/node/pull/33824
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
2020-06-15 05:52:33 +02:00
James M Snell
dd8183632d
src: add node_crypto_common and refactor
...
Two things in one on this commit:
(a) For the QUIC implementation, we need to separate out various bits
from node_crypto.cc to allow them to be reused. That's where this
commit starts.
(b) Quite a bit of the node_crypto.cc code was just messy in terms of
it's organization and lack of error handling and use of Local vs.
MaybeLocal. This cleans that up a bit and hopefully makes certain
parts a bit more manageable also.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/32016
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
2020-03-02 16:27:19 -08:00
Yaniv Friedensohn
a0e2c6d284
src: add error codes to errors thrown in C++
...
PR-URL: https://github.com/nodejs/node/pull/27700
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2019-08-09 15:58:58 -07:00
Anna Henningsen
31147c4704
buffer: do not affect memory after target for utf16 write
...
Do not write one character too much before shifting the whole result
to the left when using UTF16-LE, possibly overwriting already-used
memory while doing so.
Fixes: https://github.com/nodejs/node/issues/26422
PR-URL: https://github.com/nodejs/node/pull/26432
Fixes: https://github.com/nodejs/node/issues/26422
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Minwoo Jung <minwoo@nodesource.com >
2019-03-07 00:40:21 +01:00
gengjiawen
8137668c53
src: apply clang-tidy rule modernize-deprecated-headers
...
PR-URL: https://github.com/nodejs/node/pull/26159
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-02-27 05:35:53 +01:00
Joyee Cheung
1838d00eba
src: reduce includes of node_internals.h
...
PR-URL: https://github.com/nodejs/node/pull/25507
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-01-21 07:54:42 +01:00
Anna Henningsen
71f633a32f
src: allow UTF-16 in generic StringBytes decode call
...
This allows removing a number of special cases in other
parts of the code, at least one of which was incorrect
in expecting aligned input when that was not guaranteed.
Fixes: https://github.com/nodejs/node/issues/22358
PR-URL: https://github.com/nodejs/node/pull/22622
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2018-09-03 22:33:42 +02:00
Ujjwal Sharma and Michaël Zasso
a55c57b8c4
src: rework (mostly internal) functions to use Maybes
...
Rework all affected functions to use Maybes, thus improving error
handling substantially in internal functions, API functions as well as
utilities.
Co-authored-by: Michaël Zasso <targos@protonmail.com >
PR-URL: https://github.com/nodejs/node/pull/21935
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-09-02 14:25:16 +02:00
Ujjwal Sharma
67403b3a84
src: remove calls to deprecated v8 functions (ToString)
...
Remove all calls to deprecated v8 functions (here: Value::ToString)
inside the code (src directory only).
PR-URL: https://github.com/nodejs/node/pull/21935
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-09-02 14:24:58 +02:00
Michaël Zasso
b2f0cfa6b0
src: use String::Utf8Length with isolate
...
PR-URL: https://github.com/nodejs/node/pull/22531
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-08-29 12:28:19 +02:00
Michaël Zasso
a64fd7f320
src: use String::Write{OneByte,Utf8} with isolate
...
PR-URL: https://github.com/nodejs/node/pull/22531
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-08-29 12:28:14 +02:00
Rod Vagg
88105c998e
buffer: avoid overrun on UCS-2 string write
...
CVE-2018-12115
Discovered by ChALkeR - Сковорода Никита Андреевич
Fix by Anna Henningsen
Writing to the second-to-last byte with UCS-2 encoding will cause a -1
length to be send to String::Write(), writing all of the provided Buffer
from that point and beyond.
Fixes: https://github.com/nodejs-private/security/issues/203
PR-URL: https://github.com/nodejs-private/node-private/pull/138
2018-08-16 19:14:15 +10:00
XhmikosR
998f9ffd42
src,tools: use https://nodejs.org URL when possible.
...
PR-URL: https://github.com/nodejs/node/pull/21719
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-07-14 11:57:59 +02:00
Joyee Cheung
362694401f
src: rename ERR_STRING_TOO_LARGE to ERR_STRING_TOO_LONG
...
The old error name and message were trying to be consistent with
ERR_BUFFER_TOO_LARGE but they were not really accurate.
The kStringMaxLength was measured in number of characters,
not number of bytes. The name ERR_STRING_TOO_LARGE also
seems a bit awkward. This patch tries to correct them before
they get released to users.
PR-URL: https://github.com/nodejs/node/pull/19864
Refs: https://github.com/nodejs/node/pull/19739
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
2018-04-10 01:08:10 +02:00
Joyee Cheung
63eb267c34
src: migrate string_bytes.cc to throw errors with code
...
PR-URL: https://github.com/nodejs/node/pull/19739
Fixes: https://github.com/nodejs/node/issues/3175
Fixes: https://github.com/nodejs/node/issues/9489
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-04-07 17:15:13 +08:00
Joyee Cheung
e5f8924064
buffer: reduce overhead of StringBytes::Encode for UCS2
...
Currently calling StringBytes::Encode on a UCS2 buffer
results in two copies of the buffer and the usage of
std::vector::assign makes the memory usage unpredictable,
and therefore hard to test against.
This patch makes the memory usage more predictable by
allocating the memory using node::UncheckedMalloc and
handles the memory allocation failure properly. Only
one copy of the buffer will be created and it will
be freed upon GC of the string.
PR-URL: https://github.com/nodejs/node/pull/19798
Refs: https://github.com/nodejs/node/pull/19739
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-07 11:50:06 +08:00
Sarat Addepalli
c6c957d3cc
src: fix upcoming V8 deprecation warnings
...
PR-URL: https://github.com/nodejs/node/pull/19490
Fixes: https://github.com/nodejs/node/issues/18909
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2018-03-23 08:50:03 +01:00
Ben Noordhuis
b2b9d11a14
src: fix fs.write() externalized string handling
...
* Respect `encoding` argument when the string is externalized.
* Copy the string when the write request can outlive the externalized
string.
This commit removes `StringBytes::GetExternalParts()` because it is
fundamentally broken.
Fixes: https://github.com/nodejs/node/issues/18146
PR-URL: https://github.com/nodejs/node/pull/18216
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2018-01-23 19:17:39 +01:00
Anna Henningsen
84063a7314
src: do not include internals from node_buffer.h
...
`node_buffer.h` is a public header, so it should not be using
the `node_internals.h` internal header.
Ref: 290315ace7
Fixes: https://github.com/nodejs/node/issues/15552
PR-URL: https://github.com/nodejs/node/pull/15554
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com >
2017-09-22 16:28:52 +02:00