James M Snell
7f1c95aee8
src: make a number of minor improvements to buffer
...
When using Buffer::New with an externally allocated buffer and
v8 sandbox enabled, defer to copy instead of wrapping the buffer.
Also, when immediately memcpy'ing into the full buffer, allocate
the buffer with kUninitialized as a slight perf optimization.
PR-URL: https://github.com/nodejs/node/pull/58377
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com >
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com >
2025-05-31 13:30:46 +02:00
Tobias Nießen
d50b8a8815
src: remove void* -> char* -> void* casts
...
When passing the return value of `BackingStore::Data()` as the first or
second argument to `memcpy()`, it is unnecessary to cast the returned
pointer to `char*`.
Refs: https://github.com/nodejs/node/pull/52292
PR-URL: https://github.com/nodejs/node/pull/57791
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-05-02 17:06:15 -03:00
James M Snell
869ea331f3
src: replace NoArrayBufferZeroFillScope with v8 option
...
NoArrayBufferZeroFillScope was added before the v8 option to
create uninitialized backing stores was added. We can start
moving away from it.
PR-URL: https://github.com/nodejs/node/pull/56658
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-01-23 15:02:04 -08:00
Michaël Zasso
c93e256ee7
src: use args.This() instead of Holder
...
The latter is deprecated in V8.
Refs: http://crbug.com/333672197
PR-URL: https://github.com/nodejs/node/pull/53474
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
2024-06-18 16:02:42 +00:00
Igor Sheludko
bd151552ef
src: use new V8 API to define stream accessor
...
Define XxxStream.prototype.onread as an accessor in JavaScript sense.
Previously it was defined via soon-to-be-deprecated
`v8::ObjectTemplate::SetAccessor(..)` which used to call setter even
for property stores via stream object.
The replacement V8 API `v8::ObjectTemplate::SetNativeDataProperty(..)`
defines a properly behaving data property and thus a store to a stream
object will not trigger the "onread" setter callback.
In order to preserve the desired behavior of storing the value in the
receiver's internal field the "onread" property should be defined as
a proper JavaScript accessor.
PR-URL: https://github.com/nodejs/node/pull/53084
Refs: https://github.com/v8/v8/commit/46c241eb99557fe8205acac5c526650c3847d180
Refs: https://github.com/v8/v8/commit/6ec883986bd417e2a42ddb960bd9449deb7e4639
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2024-05-27 11:57:10 +00:00
Michaël Zasso and Joyee Cheung
ec1550407b
src: stop using v8::BackingStore::Reallocate
...
It's being deprecated by V8.
Explicitly allocate a new ArrayBuffer and copy the data when needed
instead.
Fixes: https://github.com/nodejs/node/issues/52234
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/52292
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2024-04-05 09:20:10 +00:00
ywave620
461ffcadff
src,stream: improve WriteString
...
Introduce HasDoTryWrite and make use of it in WriteString
PR-URL: https://github.com/nodejs/node/pull/51155
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2023-12-30 10:48:03 +00:00
Joyee Cheung
5f2539cd9a
src: cast v8::Object::GetInternalField() return value to v8::Value
...
In preparation of https://chromium-review.googlesource.com/c/v8/v8/+/4707972
which changes the return value to v8::Data.
PR-URL: https://github.com/nodejs/node/pull/48943
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
2023-08-02 02:14:35 +00:00
Joyee Cheung
5466bec2c5
bootstrap: initialize per-isolate properties of bindings separately
...
This patch moves the initialization of per-isolate properties of
the bindings that are in the embedded snapshot separate from the
initialization of their per-context properties. This is necessary
for workers to share the isolate snapshot with the main thread
and deserialize these properties instead of creating them from
scratch.
PR-URL: https://github.com/nodejs/node/pull/47768
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2023-05-03 13:15:10 +00:00
lilsweetcaligula
97d3912eb8
src: slim down stream_base-inl.h
...
PR-URL: https://github.com/nodejs/node/pull/46972
Refs: https://github.com/nodejs/node/issues/43712
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com >
2023-04-11 05:52:27 +00:00
Chengzhong Wu
bb40507f3e
src: distinguish env stopping flags
...
`Environment::FreeEnvironment` creates a
`DisallowJavascriptExecutionScope`, so the flag
`Environment::can_call_into_js()` should also be set as `false`. As
`Environment::can_call_into_js_` is a simple boolean flag, it should not
be accessed off-threads.
PR-URL: https://github.com/nodejs/node/pull/45907
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-01-14 09:59:17 +00:00
Santiago Gimeno
34af1f69b9
src: fix crash on OnStreamRead on Windows
...
On Windows it's perfectly possible that the `uv_tcp_t` `read_cb` is
called with an error and a null `uv_buf_t` if it corresponds to a
`UV_HANDLE_ZERO_READ` read. Handle this case without crashing.
Fixes: https://github.com/nodejs/node/issues/40764
PR-URL: https://github.com/nodejs/node/pull/45878
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-12-28 11:59:51 +00:00
ywave620
78d280a768
src,stream: improve DoWrite() and Write()
...
Clarify StreamResource::DoWrite() interface definition.
Fix error-prone Http2Stream::DoWrite().
Change StreamBase::Write() to allow caller to avoid
inefficient write behavior.
PR-URL: https://github.com/nodejs/node/pull/44434
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2022-10-10 11:00:23 +00:00
legendecas
a7e5b413ef
src: split property helpers from node::Environment
...
PR-URL: https://github.com/nodejs/node/pull/44056
Refs: https://github.com/nodejs/node/issues/42528
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Feng Yu <F3n67u@outlook.com >
2022-08-02 00:01:02 +08:00
Darshan Sen
ef70718552
src: register StreamBase while registering LibuvStreamWrap
...
This resolves this TODO -
https://github.com/nodejs/node/blob/71071f896aa9696b5d36bb3bec1c7217e7420509/src/stream_wrap.cc#L111-L112 .
Signed-off-by: Darshan Sen <raisinten@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/43321
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-06-17 09:33:06 +01:00
Darshan Sen
f91dcc205d
src: delete AllocatedBuffer
...
Since all its uses are now gone, it's time to say goodbye to
AllocatedBuffer.
Refs: https://github.com/nodejs/node/pull/39941
Signed-off-by: Darshan Sen <raisinten@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/43008
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2022-05-13 15:24:13 +01:00
Keyhan Vakil
0fc1cf478f
worker: fix stream racing with terminate
...
`OnStreamAfterReqFinished` uses `v8::Object::Has` to check if it needs
to call `oncomplete`. `v8::Object::Has` needs to execute Javascript.
However when worker threads are involved, `OnStreamAfterReqFinished` may
be called after the worker thread termination has begun via
`worker.terminate()`. This makes `v8::Object::Has` return `Nothing`,
which triggers an assert.
This diff fixes the issue by simply defaulting us to `false` in the case
where `Nothing` is returned. This is sound because we can't execute
`oncomplete` anyway as the isolate is terminating.
Fixes: https://github.com/nodejs/node/issues/38418
PR-URL: https://github.com/nodejs/node/pull/42874
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-05-06 23:01:04 +01:00
Darshan Sen
516cdcd8aa
src,stream: remove *Check*() calls from non-Initialize() functions
...
There is no need to crash the process if any of these checks fail.
Signed-off-by: Darshan Sen <darshan.sen@postman.com >
PR-URL: https://github.com/nodejs/node/pull/40425
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-10-20 15:32:54 +00:00
Darshan Sen
a784258444
src: remove usage of AllocatedBuffer from stream_*
...
Signed-off-by: Darshan Sen <darshan.sen@postman.com >
PR-URL: https://github.com/nodejs/node/pull/40293
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-10-12 11:21:04 +05:30
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
Joyee Cheung
8aa9b772f4
bootstrap: include fs module into the builtin snapshot
...
PR-URL: https://github.com/nodejs/node/pull/36943
Fixes: https://github.com/nodejs/node/issues/35930
Refs: https://github.com/nodejs/node/issues/35711
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-19 19:08:06 +08:00
James M Snell
b0ac080fa7
src: retain pointers to WriteWrap/ShutdownWrap
...
Avoids potential use-after-free when wrap req's are synchronously
destroyed.
CVE-ID: CVE-2020-8265
Fixes: https://github.com/nodejs-private/node-private/issues/227
Refs: https://hackerone.com/bugs?subject=nodejs&report_id=988103
PR-URL: https://github.com/nodejs-private/node-private/pull/23
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-01-04 17:10:40 +00:00
Anna Henningsen
78e58755f7
http2,tls: store WriteWrap using BaseObjectPtr
...
Create weak `WriteWrap` and `ShutdownWrap` objects, and when
referencing them in C++ is necessary, use `BaseObjectPtr<>`
instead of plain pointers to keep these objects from being
garbage-collected.
This solves issues that arise when the underlying `StreamBase`
instance is weak, but the `WriteWrap` or `ShutdownWrap` instances
are not; in that case, they would otherwise potentially stick
around in memory after the stream that they originally belong
to is long gone.
It probably makes sense to use `BaseObjectptr<>` more extensively
in `StreamBase` in the long run as well.
PR-URL: https://github.com/nodejs/node/pull/35488
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-10-06 13:26:33 +02:00
James M Snell
b06fe33de1
quic: use async _construct for QuicStream
...
PR-URL: https://github.com/nodejs/node/pull/34351
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-07-23 06:52:59 -07:00
James M Snell
086c916997
quic: extensive refactoring of QuicStream lifecycle
...
This one was a bit of a rabbit hole... but, with this set of
changes, `QuicStream` should now work with autoDestroy, supports
a promisified `close()`, and fixes a number of other internal
bugs that were spotted trying to get it to work.
PR-URL: https://github.com/nodejs/node/pull/34351
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-07-23 06:52:53 -07:00
James M Snell
56ff1ee55a
src: extract AllocatedBuffer from env.h
...
Cleanup up env.h by removing things that are not
specific to `Environment`.
PR-URL: https://github.com/nodejs/node/pull/33291
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: David Carlier <devnexen@gmail.com >
2020-05-30 16:20:00 -07:00
Santiago Gimeno
c7a235f0a7
net: fix crash if POLLHUP is received
...
If the `onread` socket option is used and a `POLLHUP` event is received,
libuv returns `UV_EOF` along with a `NULL` buffer in the read callback,
causing the crash. Deal with this case.
Fixes: https://github.com/nodejs/node/issues/31823
PR-URL: https://github.com/nodejs/node/pull/32590
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-04-06 02:58:53 +02:00
James M Snell
ffdf1dec85
src: clean up stream_base.h and stream-base-inl.h
...
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/32307
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
2020-03-19 05:22:53 -07:00
James M Snell
0fac393d26
src: improve handling of internal field counting
...
Change suggested by bnoordhuis.
Improve handing of internal field counting by using enums.
Helps protect against future possible breakage if field
indexes are ever changed or added to.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/31960
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-03-02 10:58:36 -08:00
Anna Henningsen
973f324463
child_process,cluster: allow using V8 serialization API
...
Add an `serialization` option that allows child process IPC to
use the (typically more powerful) V8 serialization API.
Fixes: https://github.com/nodejs/node/issues/10965
PR-URL: https://github.com/nodejs/node/pull/30162
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2019-11-05 23:07:04 +01:00
Brian White and Anna Henningsen
8292b280ec
net: allow reading data into a static buffer
...
Co-Authored-By: Anna Henningsen <anna@addaleax.net >
PR-URL: https://github.com/nodejs/node/pull/25436
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2019-08-23 17:05:52 -04:00
Sam Roberts
060d901f87
src: replace FromJust() with Check() when possible
...
FromJust() is often used not for its return value, but for its
side-effects. In these cases, Check() exists, and is more clear as to
the intent. From its comment:
To be used, where the actual value of the Maybe is not needed, like
Object::Set.
See: https://github.com/nodejs/node/pull/26929/files#r269256335
PR-URL: https://github.com/nodejs/node/pull/27162
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
2019-04-12 12:33:37 -07:00
Anna Henningsen
3018441304
src: store onread callback in internal field
...
This gives a slight performance improvement. At 2000 runs:
confidence improvement accuracy (*) (**) (***)
net/net-c2s.js dur=5 type='buf' len=64 *** 0.54 % ±0.16% ±0.21% ±0.27%
PR-URL: https://github.com/nodejs/node/pull/26837
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2019-03-26 14:48:56 +01:00
gengjiawen
cf51ee4dcf
src: elevate v8 namespaces for PropertyAttribute
...
PR-URL: https://github.com/nodejs/node/pull/26681
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
2019-03-18 20:22:13 +08:00
Refael Ackermann
f2064dfc1f
src: de-lint header usage
...
PR-URL: https://github.com/nodejs/node/pull/26306
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2019-03-12 09:57:19 -04:00
Anna Henningsen
560466c773
lib,src: remove usage of _externalStream
...
Since 4697e1b0d7 , it is no longer
necessary to use `v8::External`s to pass `StreamBase` instances
to native functions.
PR-URL: https://github.com/nodejs/node/pull/26510
Refs: https://github.com/nodejs/node/pull/25142
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-03-11 09:32:40 +01:00
Jon Moss
4697e1b0d7
src: remove templating from StreamBase
...
PR-URL: https://github.com/nodejs/node/pull/25142
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-03-08 09:25:30 +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
Anna Henningsen
84e02b178a
src: allocate Buffer memory using ArrayBuffer allocator
...
Always use the right allocator for memory that is turned into
an `ArrayBuffer` at a later point.
This enables embedders to use their own `ArrayBuffer::Allocator`s,
and is inspired by Electron’s electron/node@f61bae3440 . It should
render their downstream patch unnecessary.
Refs: https://github.com/electron/node/commit/f61bae3440e1bfcc83bba6ff0785adfb89b4045e
PR-URL: https://github.com/nodejs/node/pull/26207
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-02-25 02:01:11 +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
kiyomizumia
71bc7e1ce6
src: add DCHECK macros
...
This adds check statements for debugging and refactors the code
accordingly.
PR-URL: https://github.com/nodejs/node/pull/24359
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-12-24 10:41:15 +01:00
Daniel Bevenius
344d33eef1
src: fix v8 compiler warnings in src
...
This commit changes the code to use the maybe version.
PR-URL: https://github.com/nodejs/node/pull/24246
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Refael Ackermann <refack@gmail.com >
2018-11-11 08:02:30 +01:00
Daniel Bevenius
2ea70eae73
src: fix compiler warning for debug build
...
This commit updates the check of the offset argument passed to
CallJSOnreadMethod to avoid doing a cast as this currently generates
the following compiler warning when doing a debug build:
./src/stream_base.cc:295:3:
warning: comparison of integers of different signs:
'int32_t' (aka 'int') and 'size_t' (aka 'unsigned long')
[-Wsign-compare]
CHECK_EQ(static_cast<int32_t>(offset), offset);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
PR-URL: https://github.com/nodejs/node/pull/23994
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matheus Marchini <mat@mmarchini.me >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-11-03 00:13:09 -07:00
Anna Henningsen
f01518edfd
src: improve StreamBase write throughput
...
Improve performance by transferring information about write status
to JS through an `AliasedBuffer`, rather than object properties
set from C++.
PR-URL: https://github.com/nodejs/node/pull/23843
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
2018-10-28 15:15:15 +01:00
Anna Henningsen
1365f657b5
src: improve StreamBase read throughput
...
Improve performance by providing JS with the raw ingridients
for the read data, i.e. an `ArrayBuffer` + offset + length
fields, instead of creating `Buffer` instances in C++ land.
PR-URL: https://github.com/nodejs/node/pull/23797
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-10-24 09:57:42 +02:00
Cody Hazelwood
810c0d99d1
src: use MallocedBuffer abstraction for buffers
...
Drop `Free` and `std::unique_ptr` in favor of Node's `MallocedBuffer`
for `char[]` buffer memory mangement.
PR-URL: https://github.com/nodejs/node/pull/23543
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
2018-10-15 12:03:08 +02:00
cjihrig
f7bfbb8136
src: reduce variable scope in stream_base.cc
...
PR-URL: https://github.com/nodejs/node/pull/23297
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-10-09 08:33:38 -04: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
Anna Henningsen
3217e8e66f
src: re-add Realloc() shrink after reading stream data
...
This would otherwise keep a lot of unused memory lying around,
and in particular add up to a page per chunk of memory overhead
for network reads, potentially opening a DoS vector if the resulting
`Buffer` objects are kept around indefinitely (e.g. stored in a list
and not concatenated until the socket finishes).
This fixes CVE-2018-7164.
Refs: https://github.com/nodejs-private/security/issues/186
Refs: https://github.com/nodejs/node/commit/7c4b09b24bbe7d6a8cbad256f47b30a101a909ea
PR-URL: https://github.com/nodejs-private/node-private/pull/128
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Evan Lucas <evanlucas@me.com >
2018-06-12 20:46:15 -04:00
Anna Henningsen
0cb3325f12
tls: fix SSL write error handling
...
Fix an use-after-free bug in the TLS implementation.
If we return from `DoWrite()` with an early error, we should
not be storing the `WriteWrap` object and complete it
again at a later point, when it has already been freed
(because of the write error).
This issue was reported by Jordan Zebor at F5 Networks,
who also helped with investigating this bug and coming
up with a reproduction.
This fixes CVE-2018-7162.
Fixes: https://github.com/nodejs-private/security/issues/189
PR-URL: https://github.com/nodejs-private/node-private/pull/127
Reviewed-By: Evan Lucas <evanlucas@me.com >
2018-06-12 20:46:03 -04:00