test: simplify regression test for SEGV
Test was introduced in 08a5b442e4 as a regression test, and has evolved since then. Simplify the test so that it doesn't rely on an undocumented argument to tls.createSecureCredentials(). See: https://github.com/nodejs/node-v0.x-archive/issues/6690 Confirmation that this reworked test triggers the original bug: %) % node > process.version 'v0.10.48' > credentials = crypto.createCredentials() { context: {} } > context = credentials.context {} > notcontext = { setOptions: context.setOptions } { setOptions: [Function: setOptions] } > notcontext.setOptions() node: ../src/node_object_wrap.h:61: static T* node::ObjectWrap::Unwrap(v8::Handle<v8::Object>) [with T = node::crypto::SecureContext]: Assertion `handle->InternalFieldCount() > 0' failed. zsh: abort (core dumped) node PR-URL: https://github.com/nodejs/node/pull/24241 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
3ffc84a46d
commit
624a242b05
@ -38,19 +38,19 @@ const tls = require('tls');
|
|||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Test Certificates
|
// Test Certificates
|
||||||
const caPem = fixtures.readSync('test_ca.pem', 'ascii');
|
|
||||||
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
|
||||||
const certPfx = fixtures.readSync('test_cert.pfx');
|
const certPfx = fixtures.readSync('test_cert.pfx');
|
||||||
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
|
||||||
|
|
||||||
// 'this' safety
|
// 'this' safety
|
||||||
// https://github.com/joyent/node/issues/6690
|
// https://github.com/joyent/node/issues/6690
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
const options = { key: keyPem, cert: certPem, ca: caPem };
|
const credentials = tls.createSecureContext();
|
||||||
const credentials = tls.createSecureContext(options);
|
|
||||||
const context = credentials.context;
|
const context = credentials.context;
|
||||||
const notcontext = { setOptions: context.setOptions, setKey: context.setKey };
|
const notcontext = { setOptions: context.setOptions };
|
||||||
tls.createSecureContext({ secureOptions: 1 }, notcontext);
|
|
||||||
|
// Methods of native objects should not segfault when reassigned to a new
|
||||||
|
// object and called illegally. This core dumped in 0.10 and was fixed in
|
||||||
|
// 0.11.
|
||||||
|
notcontext.setOptions();
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
// Throws TypeError, so there is no opensslErrorStack property.
|
// Throws TypeError, so there is no opensslErrorStack property.
|
||||||
if ((err instanceof Error) &&
|
if ((err instanceof Error) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user