Skip to content

Commit f808e7a

Browse files
theanarkhUlisesGascon
authored andcommitted
net: check pipe mode and path
PR-URL: #50770 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 932a5d7 commit f808e7a

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

lib/net.js

+6
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,12 @@ Server.prototype.listen = function(...args) {
20142014
// (path[, backlog][, cb]) or (options[, cb])
20152015
// where path or options.path is a UNIX domain socket or Windows pipe
20162016
if (options.path && isPipeName(options.path)) {
2017+
// We can not call fchmod on abstract unix socket
2018+
if (options.path[0] === '\0' &&
2019+
(options.readableAll || options.writableAll)) {
2020+
const msg = 'can not set readableAll or writableAllt to true when path is abstract unix socket';
2021+
throw new ERR_INVALID_ARG_VALUE('options', options, msg);
2022+
}
20172023
const pipeName = this._pipeName = options.path;
20182024
backlog = options.backlog || backlogFromArgs;
20192025
listenInCluster(this,
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const net = require('net');
5+
6+
if (!common.isLinux) common.skip();
7+
8+
const path = '\0abstract';
9+
const message = /can not set readableAll or writableAllt to true when path is abstract unix socket/;
10+
11+
assert.throws(() => {
12+
const server = net.createServer(common.mustNotCall());
13+
server.listen({
14+
path,
15+
readableAll: true
16+
});
17+
}, message);
18+
19+
assert.throws(() => {
20+
const server = net.createServer(common.mustNotCall());
21+
server.listen({
22+
path,
23+
writableAll: true
24+
});
25+
}, message);
26+
27+
assert.throws(() => {
28+
const server = net.createServer(common.mustNotCall());
29+
server.listen({
30+
path,
31+
readableAll: true,
32+
writableAll: true
33+
});
34+
}, message);

0 commit comments

Comments
 (0)