Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f6745e9

Browse filesBrowse files
eladkishontargos
authored andcommitted
tls: fix tlsSocket.setMaxSendFragment abort
PR-URL: #38170 Fixes: #38169 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 2eef587 commit f6745e9
Copy full SHA for f6745e9

File tree

Expand file treeCollapse file tree

2 files changed

+28
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+28
-3
lines changed
Open diff view settings
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ const {
8686
const {
8787
validateBuffer,
8888
validateCallback,
89+
validateInt32,
8990
validateObject,
9091
validateString,
91-
validateUint32
92+
validateUint32,
9293
} = require('internal/validators');
9394
const {
9495
InternalX509Certificate
@@ -893,6 +894,7 @@ TLSSocket.prototype.exportKeyingMaterial = function(length, label, context) {
893894
};
894895

895896
TLSSocket.prototype.setMaxSendFragment = function setMaxSendFragment(size) {
897+
validateInt32(size, 'size');
896898
return this._handle.setMaxSendFragment(size) === 1;
897899
};
898900

Collapse file

‎test/parallel/test-tls-max-send-fragment.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-max-send-fragment.js
+25-2Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,38 @@ const buf = Buffer.allocUnsafe(10000);
3333
let received = 0;
3434
const maxChunk = 768;
3535

36+
const invalidArgumentError = {
37+
name: 'TypeError',
38+
code: 'ERR_INVALID_ARG_TYPE'
39+
};
40+
3641
const server = tls.createServer({
3742
key: fixtures.readKey('agent1-key.pem'),
3843
cert: fixtures.readKey('agent1-cert.pem')
3944
}, function(c) {
40-
// Lower and upper limits
45+
46+
// No size is passed.
47+
assert.throws(() => c.setMaxSendFragment(), invalidArgumentError);
48+
49+
// Invalid arg is passed.
50+
[null, undefined, '', {}, false, true, []].forEach((arg) => {
51+
assert.throws(() => c.setMaxSendFragment(arg), invalidArgumentError);
52+
});
53+
54+
[NaN, Infinity, 2 ** 31].forEach((arg) => {
55+
assert.throws(() => c.setMaxSendFragment(arg), {
56+
name: 'RangeError',
57+
code: 'ERR_OUT_OF_RANGE'
58+
});
59+
});
60+
61+
assert.throws(() => c.setMaxSendFragment(Symbol()), { name: 'TypeError' });
62+
63+
// Lower and upper limits.
4164
assert(!c.setMaxSendFragment(511));
4265
assert(!c.setMaxSendFragment(16385));
4366

44-
// Correct fragment size
67+
// Correct fragment size.
4568
assert(c.setMaxSendFragment(maxChunk));
4669

4770
c.end(buf);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.