tls: check arg types of renegotiate()
Don't throw on invalid property access if options is not provided, and ensure callback is a function. PR-URL: https://github.com/nodejs/node/pull/25876 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
c6ecbd36fa
commit
6b7c402518
@ -39,6 +39,7 @@ const { owner_symbol } = require('internal/async_hooks').symbols;
|
|||||||
const { SecureContext: NativeSecureContext } = internalBinding('crypto');
|
const { SecureContext: NativeSecureContext } = internalBinding('crypto');
|
||||||
const {
|
const {
|
||||||
ERR_INVALID_ARG_TYPE,
|
ERR_INVALID_ARG_TYPE,
|
||||||
|
ERR_INVALID_CALLBACK,
|
||||||
ERR_MULTIPLE_CALLBACK,
|
ERR_MULTIPLE_CALLBACK,
|
||||||
ERR_SOCKET_CLOSED,
|
ERR_SOCKET_CLOSED,
|
||||||
ERR_TLS_DH_PARAM_SIZE,
|
ERR_TLS_DH_PARAM_SIZE,
|
||||||
@ -581,6 +582,11 @@ TLSSocket.prototype._init = function(socket, wrap) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TLSSocket.prototype.renegotiate = function(options, callback) {
|
TLSSocket.prototype.renegotiate = function(options, callback) {
|
||||||
|
if (options === null || typeof options !== 'object')
|
||||||
|
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
|
||||||
|
if (callback != null && typeof callback !== 'function')
|
||||||
|
throw new ERR_INVALID_CALLBACK();
|
||||||
|
|
||||||
if (this.destroyed)
|
if (this.destroyed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -47,6 +47,22 @@ server.listen(0, common.mustCall(() => {
|
|||||||
};
|
};
|
||||||
const client = tls.connect(options, common.mustCall(() => {
|
const client = tls.connect(options, common.mustCall(() => {
|
||||||
client.write('');
|
client.write('');
|
||||||
|
|
||||||
|
common.expectsError(() => client.renegotiate(), {
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
|
type: TypeError,
|
||||||
|
});
|
||||||
|
|
||||||
|
common.expectsError(() => client.renegotiate(common.mustNotCall()), {
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
|
type: TypeError,
|
||||||
|
});
|
||||||
|
|
||||||
|
common.expectsError(() => client.renegotiate({}, false), {
|
||||||
|
code: 'ERR_INVALID_CALLBACK',
|
||||||
|
type: TypeError,
|
||||||
|
});
|
||||||
|
|
||||||
// Negotiation is still permitted for this first
|
// Negotiation is still permitted for this first
|
||||||
// attempt. This should succeed.
|
// attempt. This should succeed.
|
||||||
let ok = client.renegotiate(options, common.mustCall((err) => {
|
let ok = client.renegotiate(options, common.mustCall((err) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user