0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
Commit Graph

3959 Commits

Author SHA1 Message Date
Ali Ijaz Sheikh
f7224cac62 contextify: cleanup weak ref for sandbox
Simplify how node_contextify was keeping a weak reference to the
sandbox object in order to prepare for new style phantom weakness V8
API. It is simpler (and more robust) for the context to hold a
reference to the sandbox in an embedder data field. Doing otherwise
meant that the sandbox could become weak while the context was still
alive. This wasn't a problem because we would make the reference
strong at that point.

Since the sandbox must live at least as long as the context, it
would be better for the context to hold onto the sandbox.

PR-URL: https://github.com/nodejs/node/pull/5392
Reviewed-By: Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Ali Ijaz Sheikh
5737c215b5 contextify: cleanup weak ref for global proxy
Cleanup how node_contextify keeps weak references in order to prepare
for new style phantom weakness API. We didn't need to keep a weak
reference to the context's global proxy, as the context holds it.

PR-URL: https://github.com/nodejs/node/pull/5392
Reviewed-By: Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Ali Ijaz Sheikh
ebbbc5a790 buffer: replace deprecated SetWeak usage
Old style SetWeak is now deprecated, and weakness now works like
phantom references. This means we no longer have a reference to the
object in the weak callback. We use a kInternalFields style weak
callback which provides us with the contents of 2 internal fields
where we can squirrel away the native buffer pointer.

We can no longer neuter the buffer in the weak callback, but that
should be unnecessary as the object is going to be GC'd during the
current gc cycle.

PR-URL: https://github.com/nodejs/node/pull/5204
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
2016-03-03 20:35:20 -08:00
Ali Ijaz Sheikh
34aac23d0b buffer: cleanup CallbackInfo
Dynamic checks that CallbackInfo holds an ArrayBuffer handle can be
converted into compiler enforced checks. Removed unused code, and
other minor cleanup.

PR-URL: https://github.com/nodejs/node/pull/5204
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
2016-03-03 20:35:20 -08:00
Ali Ijaz Sheikh
a45e1f9f98 src: fix deprecated SetWeak usage in base-object
PR-URL: https://github.com/nodejs/node/pull/5204
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
2016-03-03 20:35:20 -08:00
Ali Ijaz Sheikh
c1649a7e4e src: replace usage of deprecated SetAccessor
PR-URL: https://github.com/nodejs/node/pull/5204
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
2016-03-03 20:35:20 -08:00
Michaël Zasso
cddd5347f6 src: replace deprecated ProcessDebugMessages
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
d515a3f4b4 src: replace usage of deprecated GetDebugContext
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
4417f99432 src: replace usage of deprecated SetMessageHandler
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
8894f2745f src: replace deprecated CancelTerminateExecution
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
f50ef1a46f src: replace deprecated TerminateExecution
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
ac32340997 src: replace usage of deprecated HasOwnProperty
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
a729208808 src: replace usage of deprecated Has
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
3d7fd9aa22 src: replace usage of deprecated GetEndColumn
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
d45045f318 src: replace usage of deprecated Delete
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
16b0a8c1ac src: replace usage of deprecated CompileUnbound
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
023c317173 src: replace usage of deprecated Compile
PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-03 20:35:20 -08:00
Michaël Zasso
79d7475604 src: fix TryCatch deprecation warnings
PR-URL: https://github.com/nodejs/node/pull/4722
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2016-03-03 20:35:20 -08:00
Michaël Zasso
81f1732a05 src: replace deprecated String::NewFromOneByte
PR-URL: https://github.com/nodejs/node/pull/4722
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2016-03-03 20:35:20 -08:00
Fedor Indutny
b010c87164 crypto, string_bytes: treat buffer str as utf8
Do not treat crypto inputs as `binary` strings, convert them to Buffers
using `new Buffer(..., 'utf8')`, or using newly updated StringBytes
APIs.

PR-URL: https://github.com/nodejs/node/pull/5522
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-02 21:25:04 +03:00
Ben Noordhuis
0bea78682a tls: fix assert in context._external accessor
* Restrict the receiver to instances of the FunctionTemplate.
* Use `args.This()` instead of `args.Holder()`.

Fixes: https://github.com/nodejs/node/issues/3682
PR-URL: https://github.com/nodejs/node/pull/5521
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-03-02 17:15:56 +01:00
Trevor Norris
a7e49c886f http_parser: use MakeCallback
Make `HTTPParser` an instance of `AsyncWrap` and make it use
`MakeCallback`. This means that async wrap hooks will be called on
consumed TCP sockets as well as on non-consumed ones.

Additional uses of `AsyncCallbackScope` are necessary to prevent
improper state from progressing that triggers failure in the
test-http-pipeline-flood.js test. Optimally this wouldn't be necessary,
but for the time being it's the most sure way to allow operations to
proceed as they have.

Fix: https://github.com/nodejs/node/issues/4416
PR-URL: https://github.com/nodejs/node/pull/5419
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-03-01 02:37:27 -07:00
Fedor Indutny
da3f425506 crypto: PBKDF2 works with int not ssize_t
Change types of all PBKDF2 params to `int` as they are `int` in `evp.h`.

Check that `raw_keylen` fits into `int` before passing it to OpenSSL.

Fix: #5396
PR-URL: https://github.com/nodejs/node/pull/5397
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
Reviewed-By: Ben Noorhduis <info@bnoordhuis.nl>
2016-03-01 09:07:38 +03:00
Sam Roberts
292033b1f5 constants: define ENGINE_METHOD_RSA
constants.ENGINE_METHOD_RSA was documented, but not implemented.

PR-URL: https://github.com/nodejs/node/pull/5463
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-26 19:42:56 -08:00
Stefan Budeanu
7c48cb5601 crypto: Improve control of FIPS mode
Default to FIPS off even in FIPS builds.
Add JS API to check and control FIPS mode.
Add command line arguments to force FIPS on/off.
Respect OPENSSL_CONF variable and read the config.
Add testing for new features.

Fixes: https://github.com/nodejs/node/issues/3819
PR-URL: https://github.com/nodejs/node/pull/5181
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-by: Michael Dawson <michael_dawson@ca.ibm.com>
2016-02-25 15:06:41 -05:00
Ben Noordhuis
33e51fe18c src,tools: remove null sentinel from source array
PR-URL: https://github.com/nodejs/node/pull/5418
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-02-25 13:21:56 +01:00
Ben Noordhuis
96adbe9503 src,tools: drop nul byte from built-in source code
PR-URL: https://github.com/nodejs/node/pull/5418
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-02-25 13:21:53 +01:00
Ben Noordhuis
cdc7e025e0 src,tools: allow utf-8 in built-in js source code
PR-URL: https://github.com/nodejs/node/pull/5418
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-02-25 13:21:27 +01:00
Jiho Choi
d5c04c34f1 vm: fix produceCachedData
Fix segmentation faults when compiling the same code with
`produceCachedData` option. V8 ignores the option when the code is in
its compilation cache and does not return cached data. Added
`cachedDataProduced` property to `v8.Script` to denote whether the
cached data is produced successfully.

PR-URL: https://github.com/nodejs/node/pull/5343
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-21 14:59:35 -05:00
Phillip Kovalev
5c14efbbe9 module: return correct exports from linked binding
Method `LinkedBinding` must return the same "exports" property
of the module as cached, because property can be overridden
by an initialization function.

PR-URL: https://github.com/nodejs/node/pull/5337
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-02-20 12:48:47 +01:00
Andreas Madsen
11c672bc77 async_wrap: add parent uid to init hook
When the parent uid is required it is not necessary to store the uid in
the parent handle object.

PR-URL: https://github.com/nodejs/node/pull/4600
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-02-18 13:49:51 -07:00
Andreas Madsen
c6c7d8b325 async_wrap: make uid the first argument in init
All other hooks have uid as the first argument, this makes it consistent
for all hooks.

PR-URL: https://github.com/nodejs/node/pull/4600
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-02-18 13:49:26 -07:00
Andreas Madsen
c794869e97 async_wrap: add uid to all asyncWrap hooks
By doing this users can use a Map object for storing information instead
of modifying the handle object.

PR-URL: https://github.com/nodejs/node/pull/4600
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-02-18 13:47:24 -07:00
Rich Trott
32f6098eef src,test,tools: modify for more stringent linting
ESLint 2.1.0 is coming. Some lint rules have been tightened.

PR-URL: https://github.com/nodejs/node/pull/5214
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: jbergstroem - Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2016-02-18 10:11:26 -08:00
Brian White
b72dbdbe43 src: remove unnecessary check
The value's type is unsigned so it will always be >= 0.

PR-URL: https://github.com/nodejs/node/pull/5233
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-02-15 07:52:02 -08:00
Evan Lucas
31ebda24d4 node: set process._eventsCount to 0 on startup
process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

PR-URL: https://github.com/nodejs/node/pull/5208
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-02-15 09:33:17 -06:00
Trevor Norris
95afe28fc5 src: remove TryCatch in MakeCallback
After attempting to use ReThrow() and Reset() there were cases where
firing the domain's error handlers was not happening. Or in some cases
reentering MakeCallback would still cause the domain enter callback to
abort (because the error had not been Reset yet).

In order for the script to properly stop execution when a subsequent
call to MakeCallback throws it must not be located within a TryCatch.

PR-URL: https://github.com/nodejs/node/pull/4507
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-12 14:03:32 -07:00
Trevor Norris
5e30478ede src: remove unused TickInfo::in_tick()
PR-URL: https://github.com/nodejs/node/pull/4507
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-12 14:03:30 -07:00
Trevor Norris
f86a3a2fb5 src: remove unused of TickInfo::last_threw()
Environment::TickInfo::last_threw() is no longer in use.

Also pass Isolate to few methods and fix whitespace alignment.

PR-URL: https://github.com/nodejs/node/pull/4507
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-12 14:03:26 -07:00
Trevor Norris
e9192249c8 src: add AsyncCallbackScope
Add a scope that will allow MakeCallback to know whether or not it's
currently running. This will prevent nextTickQueue and the
MicrotaskQueue from being processed recursively. It is also required to
wrap the bootloading stage since it doesn't run within a MakeCallback.

Ref: https://github.com/nodejs/node-v0.x-archive/issues/9245
PR-URL: https://github.com/nodejs/node/pull/4507
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-12 14:03:24 -07:00
Trevor Norris
575b84ec41 src: fix MakeCallback error handling
Implementations of error handling between node::MakeCallback() and
AsyncWrap::MakeCallback() do not return at the same point. Make both
executions work the same by moving the early return if there's a caught
exception just after the AsyncWrap post callback. Since the domain's
call stack is cleared on a caught exception there is no reason to call
its exit() callback.

Remove the SetVerbose() statement in the AsyncWrap pre/post callback
calls since it does not affect the callback call.

PR-URL: https://github.com/nodejs/node/pull/4507
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-12 14:03:17 -07:00
Adam Langley
773b9016aa crypto: have fixed NodeBIOs return EOF
Prior to this change, the NodeBIO objects used to wrap fixed data had
`num` equal to -1. This caused them to return -1 and set the retry flags
when they ran out of data. Since the data is fixed, that's incorrect.
Instead they should return zero to signal EOF.

This change adds a new, static function, NodeBIO::NewFixed to create a
BIO that wraps fixed data and which returns zero when exhausted.

The practical impact of this is limited since most (all?) the parsing
functions that these BIOs get passed to consider any return value less
than one to be EOF and ignore the retry flags anyway.

PR-URL: https://github.com/nodejs/node/pull/5105
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-11 16:30:03 -05:00
Trevor Norris
b55e58042c buffer: add encoding parameter to fill()
Can now call fill() using following parameters if value is a String:

    fill(string[, start[, end]][, encoding])

And with the following if value is a Buffer:

    fill(buffer[, start[, end]])

The encoding is ignored if value is not a String. All other non-Buffer
values are coerced to a uint32.

A multibyte strings will simply be copied into the Buffer until the
number of bytes run out. Meaning partial strings can be left behind:

    Buffer(3).fill('\u0222');
    // returns: <Buffer c8 a2 c8>

In some encoding cases, such as 'hex', fill() will throw if the input
string is not valid.

PR-URL: https://github.com/nodejs/node/pull/4935
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-02-10 12:06:20 -07:00
Jackson Tian
4e46931406 src: deprecate undocumented variables
The `root` and `GLOBAL` were never documented.

PR-URL: https://github.com/nodejs/node/pull/1838
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-02-10 11:58:17 +01:00
James M Snell
b5b5bb1e3c src: avoid compiler warning in node_revert.cc
PR-URL: https://github.com/nodejs/node-private/pull/26
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-02-09 09:22:13 -08:00
James M Snell
d387591bbb src: add --security-revert command line flag
The `--security-revert={cvenum}` command line flag is a special purpose
flag to be used only in stable or LTS branches when a breaking change
is required to address a security vulnerability. Whenever a vulnerability
requires a breaking change, and a CVE has been assigned, the flag can
be used to force Node to revert to the insecure behavior that was
implemented before the fix was applied.

Note that this flag is intended to be used only as a last resort in the
case a security update breaks existing code. When used, a security
warning will be printed to stderr when Node launches.

The `--security-revert={cvenum}` flag takes a single CVE number as an
argument. Multiple instances of the `--security-revert={cvenum}` flag
can be used on the command line to revert multiple changes.

Whenever a new `--security-revert={cvenum}` is enabled, it should be
documented in the release notes and in the API docs.

Master and the first release of a new major (e.g. v6.0) should not have
any reverts available.

Every time a new `--security-revert={cvenum}` is added, there should be
a semver-minor bump in the stable and LTS branch.

PR-URL: https://github.com/nodejs/node-private/pull/26
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-02-09 09:20:41 -08:00
Ruben Bridgewater
88307974e6 node: improve process.nextTick performance
Prevent deoptimization of process.nextTick by removing the try finally
block. This is not necessary as the next tick queue will be reset
anyway, no matter if the callback throws or not.

Use a predefined array size prevents resizing the array and is therefor
faster.

PR-URL: https://github.com/nodejs/node/pull/5092
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-02-09 02:46:43 -07:00
Fedor Indutny
1258b0166d deps: sync with upstream bagder/c-ares@2bae2d5
PR-URL: https://github.com/nodejs/node/pull/5090
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-02-08 14:44:19 -05:00
Fedor Indutny
106c6cfe98 crypto: fix memory leak in LoadPKCS12
`sk_X509_pop_free` should be used instead of `sk_X509_free` to free all
items in queue too, not just the queue itself.

PR-URL: https://github.com/nodejs/node/pull/5109
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2016-02-08 14:39:25 -05:00
Fedor Indutny
23196fe9c1 crypto: add pfx certs as CA certs too
According to documentation all certificates specified in `pfx` option
should be treated as a CA certificates too. While it doesn't seem to be
logically correct to me, we can't afford to break API stability at this
point.

Fix: #5100
PR-URL: https://github.com/nodejs/node/pull/5109
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2016-02-08 14:38:45 -05:00