From 71274b0263083942e2affed0f959fe98a7366781 Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Tue, 21 Apr 2015 18:24:13 -0300 Subject: [PATCH 1/6] tls_wrap: use localhost if options.host is empty tls.connect(options) with no options.host should accept a certificate with CN: 'localhost'. Fix Error: Hostname/IP doesn't match certificate's altnames: "Host: undefined. is not cert's CN: localhost" 'localhost' is not added directly to defaults because that is not always desired (for example, when using options.socket) PR-URL: https://github.com/iojs/io.js/pull/1493 PORT-PR-URL: https://github.com/iojs/io.js/pull/1560 PORT-FROM: v2.x / a7d74633f20e285395f5e2860bdac56381603476 Fixes: https://github.com/iojs/io.js/issues/1489 Reviewed-By: Brendan Ashworth Reviewed-By: Roman Reiss --- lib/_tls_wrap.js | 3 +- test/parallel/test-tls-connect-no-host.js | 34 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-tls-connect-no-host.js diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index deb9b5ae6bfa8e..122c7042a4cf2f 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -871,7 +871,8 @@ exports.connect = function(/* [port, host], options, cb */) { var hostname = options.servername || options.host || - options.socket && options.socket._host, + (options.socket && options.socket._host) || + 'localhost', NPN = {}, context = tls.createSecureContext(options); tls.convertNPNProtocols(options.NPNProtocols, NPN); diff --git a/test/parallel/test-tls-connect-no-host.js b/test/parallel/test-tls-connect-no-host.js new file mode 100644 index 00000000000000..41aac1acabd781 --- /dev/null +++ b/test/parallel/test-tls-connect-no-host.js @@ -0,0 +1,34 @@ +var common = require('../common'); + +if (!common.hasCrypto) { + console.log('1..0 # Skipped: missing crypto'); + process.exit(); +} +var tls = require('tls'); + +var assert = require('assert'); +var fs = require('fs'); +var path = require('path'); + +var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')); +var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')); + +// https://github.com/iojs/io.js/issues/1489 +// tls.connect(options) with no options.host should accept a cert with +// CN:'localhost' +tls.createServer({ + key: key, + cert: cert +}).listen(common.PORT); + +var socket = tls.connect({ + port: common.PORT, + ca: cert, + // No host set here. 'localhost' is the default, + // but tls.checkServerIdentity() breaks before the fix with: + // Error: Hostname/IP doesn't match certificate's altnames: + // "Host: undefined. is not cert's CN: localhost" +}, function() { + assert(socket.authorized); + process.exit(); +}); From 5896fe5cd33408221981b70d7dce279b95b119ce Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Sun, 26 Apr 2015 20:59:45 +1000 Subject: [PATCH 2/6] test: adjust Makefile/test-ci, add to vcbuild.bat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/iojs/io.js/pull/1530 PORT-PR-URL: https://github.com/iojs/io.js/pull/1560 PORT-FROM: v2.x / 547213913b2e1525c15968916452995ab14e2195 Reviewed-By: Johan Bergström --- Makefile | 4 +++- vcbuild.bat | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 28fd263c94eb9c..c714e95a857c28 100644 --- a/Makefile +++ b/Makefile @@ -112,7 +112,9 @@ test-all-valgrind: test-build $(PYTHON) tools/test.py --mode=debug,release --valgrind test-ci: - $(PYTHON) tools/test.py -p tap --logfile test.tap -J parallel sequential message + $(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release -J message parallel sequential + $(MAKE) jslint + $(MAKE) cpplint test-release: test-build $(PYTHON) tools/test.py --mode=release diff --git a/vcbuild.bat b/vcbuild.bat index 44d149d32241b4..2cf94ad5fdf370 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -52,6 +52,7 @@ if /i "%1"=="noetw" set noetw=1&goto arg-ok if /i "%1"=="noperfctr" set noperfctr=1&goto arg-ok if /i "%1"=="licensertf" set licensertf=1&goto arg-ok if /i "%1"=="test" set test_args=%test_args% sequential parallel message -J&set jslint=1&goto arg-ok +if /i "%1"=="test-ci" set test_args=%test_args% -p tap --logfile test.tap -J message sequential parallel&set jslint=1&goto arg-ok if /i "%1"=="test-simple" set test_args=%test_args% sequential parallel -J&goto arg-ok if /i "%1"=="test-message" set test_args=%test_args% message&goto arg-ok if /i "%1"=="test-gc" set test_args=%test_args% gc&set buildnodeweak=1&goto arg-ok From 65dd10e9c028020d1a09fc36a02a4412b95d6cce Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 28 Apr 2015 15:01:20 +1000 Subject: [PATCH 3/6] build: remove -J from test-ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit parallel tests still not working on most build slaves PR-URL: https://github.com/iojs/io.js/pull/1544 PORT-PR-URL: https://github.com/iojs/io.js/pull/1560 PORT-FROM: v2.x / 2a3c8c187e4462f93169b6c98bea552edcace972 Reviewed-By: Johan Bergström --- Makefile | 2 +- vcbuild.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c714e95a857c28..8fc67d604e91b0 100644 --- a/Makefile +++ b/Makefile @@ -112,7 +112,7 @@ test-all-valgrind: test-build $(PYTHON) tools/test.py --mode=debug,release --valgrind test-ci: - $(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release -J message parallel sequential + $(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release message parallel sequential $(MAKE) jslint $(MAKE) cpplint diff --git a/vcbuild.bat b/vcbuild.bat index 2cf94ad5fdf370..97d6ba3bbc5511 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -52,7 +52,7 @@ if /i "%1"=="noetw" set noetw=1&goto arg-ok if /i "%1"=="noperfctr" set noperfctr=1&goto arg-ok if /i "%1"=="licensertf" set licensertf=1&goto arg-ok if /i "%1"=="test" set test_args=%test_args% sequential parallel message -J&set jslint=1&goto arg-ok -if /i "%1"=="test-ci" set test_args=%test_args% -p tap --logfile test.tap -J message sequential parallel&set jslint=1&goto arg-ok +if /i "%1"=="test-ci" set test_args=%test_args% -p tap --logfile test.tap message sequential parallel&set jslint=1&goto arg-ok if /i "%1"=="test-simple" set test_args=%test_args% sequential parallel -J&goto arg-ok if /i "%1"=="test-message" set test_args=%test_args% message&goto arg-ok if /i "%1"=="test-gc" set test_args=%test_args% gc&set buildnodeweak=1&goto arg-ok From 898d4238208e46fc0f402c6f978ae0f77cb8edce Mon Sep 17 00:00:00 2001 From: Brian White Date: Tue, 28 Apr 2015 10:53:06 -0400 Subject: [PATCH 4/6] string_decoder: don't cache Buffer.isEncoding Some modules are monkey-patching Buffer.isEncoding, so without this they cannot do that. Fixes: https://github.com/iojs/io.js/issues/1547 PR-URL: https://github.com/iojs/io.js/pull/1548 PORT-PR-URL: https://github.com/iojs/io.js/pull/1560 PORT-FROM: v2.x / 0fa6c4a6fc7ed4a2dfe821f1d3a46d5f6ff43e69 Reviewed-By: Evan Lucas Reviewed-By: Ben Noordhuis --- lib/string_decoder.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/string_decoder.js b/lib/string_decoder.js index 61a3bb20d588d3..62ea38e08f051c 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -1,9 +1,9 @@ 'use strict'; -const isEncoding = Buffer.isEncoding; - function assertEncoding(encoding) { - if (encoding && !isEncoding(encoding)) { + // Do not cache `Buffer.isEncoding`, some modules monkey-patch it to support + // additional encodings + if (encoding && !Buffer.isEncoding(encoding)) { throw new Error('Unknown encoding: ' + encoding); } } From 4030545af609cefbb698dbbca721be8977cedf9f Mon Sep 17 00:00:00 2001 From: Julian Duque Date: Tue, 28 Apr 2015 15:15:41 -0500 Subject: [PATCH 5/6] fs: validate fd on fs.write PR-URL: #1553 PORT-PR-URL: https://github.com/iojs/io.js/pull/1560 PORT-FROM: v2.x / f9c681cf627caf89b5c7eaacf154fdefb747c7e0 Reviewed-By: Colin Ihrig --- src/node_file.cc | 4 +++- test/parallel/test-fs-write-no-fd.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-fs-write-no-fd.js diff --git a/src/node_file.cc b/src/node_file.cc index d466acc65a9dc0..095710ef37e32b 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -779,7 +779,9 @@ static void Open(const FunctionCallbackInfo& args) { static void WriteBuffer(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - CHECK(args[0]->IsInt32()); + if (!args[0]->IsInt32()) + return env->ThrowTypeError("First argument must be file descriptor"); + CHECK(Buffer::HasInstance(args[1])); int fd = args[0]->Int32Value(); diff --git a/test/parallel/test-fs-write-no-fd.js b/test/parallel/test-fs-write-no-fd.js new file mode 100644 index 00000000000000..143928e7836ea7 --- /dev/null +++ b/test/parallel/test-fs-write-no-fd.js @@ -0,0 +1,11 @@ +const common = require('../common'); +const fs = require('fs'); +const assert = require('assert'); + +assert.throws(function() { + fs.write(null, new Buffer(1), 0, 1); +}, /TypeError/); + +assert.throws(function() { + fs.write(null, '1', 0, 1); +}, /TypeError/); From 32a6dbcf23d86386800551967c2df06e156d6a62 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Wed, 29 Apr 2015 10:55:55 +1000 Subject: [PATCH 6/6] test: extend timeouts for ARMv6 Based on tests running on original Raspberry Pi PR-URL: https://github.com/iojs/io.js/pull/1554 PORT-PR-URL: https://github.com/iojs/io.js/pull/1560 PORT-FROM: v2.x / f9b226c1c1e5bfbf355f9fabe03e50333676cc05 Reviewed-By: Roman Reiss --- test/common.js | 2 +- test/parallel/test-child-process-fork-net2.js | 2 +- test/parallel/test-debug-signal-cluster.js | 2 +- test/sequential/test-next-tick-error-spin.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/common.js b/test/common.js index 1e85d3db33be48..ec0b387328d6b7 100644 --- a/test/common.js +++ b/test/common.js @@ -184,7 +184,7 @@ exports.platformTimeout = function(ms) { return ms; if (process.config.variables.arm_version === '6') - return 6 * ms; // ARMv6 + return 7 * ms; // ARMv6 return 2 * ms; // ARMv7 and up. }; diff --git a/test/parallel/test-child-process-fork-net2.js b/test/parallel/test-child-process-fork-net2.js index c69fe84eadd787..150e9cfc4544e9 100644 --- a/test/parallel/test-child-process-fork-net2.js +++ b/test/parallel/test-child-process-fork-net2.js @@ -150,7 +150,7 @@ if (process.argv[2] === 'child') { }; var min = 190; - var max = common.platformTimeout(1500); + var max = common.platformTimeout(2000); process.on('exit', function() { assert.equal(disconnected, count); assert.equal(connected, count); diff --git a/test/parallel/test-debug-signal-cluster.js b/test/parallel/test-debug-signal-cluster.js index c8b03875908a5a..772ee6f1e6f454 100644 --- a/test/parallel/test-debug-signal-cluster.js +++ b/test/parallel/test-debug-signal-cluster.js @@ -51,7 +51,7 @@ function onNoMoreLines() { setTimeout(function testTimedOut() { assert(false, 'test timed out.'); -}, common.platformTimeout(3000)).unref(); +}, common.platformTimeout(4000)).unref(); process.on('exit', function onExit() { // Kill processes in reverse order to avoid timing problems on Windows where diff --git a/test/sequential/test-next-tick-error-spin.js b/test/sequential/test-next-tick-error-spin.js index c8011115c04f0e..a150ea7a589f63 100644 --- a/test/sequential/test-next-tick-error-spin.js +++ b/test/sequential/test-next-tick-error-spin.js @@ -8,7 +8,7 @@ if (process.argv[2] !== 'child') { }); var timer = setTimeout(function() { throw new Error('child is hung'); - }, 3000); + }, common.platformTimeout(3000)); child.on('exit', function(code) { console.error('ok'); assert(!code);