mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
net: check pipe mode and path
PR-URL: https://github.com/nodejs/node/pull/50770 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
2c7d23311c
commit
51abedecc5
2 files changed
+40
No files matched your search
@@ -2014,6 +2014,12 @@ Server.prototype.listen = function(...args) {
|
||||
// (path[, backlog][, cb]) or (options[, cb])
|
||||
// where path or options.path is a UNIX domain socket or Windows pipe
|
||||
if (options.path && isPipeName(options.path)) {
|
||||
// We can not call fchmod on abstract unix socket
|
||||
if (options.path[0] === '\0' &&
|
||||
(options.readableAll || options.writableAll)) {
|
||||
const msg = 'can not set readableAll or writableAllt to true when path is abstract unix socket';
|
||||
throw new ERR_INVALID_ARG_VALUE('options', options, msg);
|
||||
}
|
||||
const pipeName = this._pipeName = options.path;
|
||||
backlog = options.backlog || backlogFromArgs;
|
||||
listenInCluster(this,
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const net = require('net');
|
||||
|
||||
if (!common.isLinux) common.skip();
|
||||
|
||||
const path = '\0abstract';
|
||||
const message = /can not set readableAll or writableAllt to true when path is abstract unix socket/;
|
||||
|
||||
assert.throws(() => {
|
||||
const server = net.createServer(common.mustNotCall());
|
||||
server.listen({
|
||||
path,
|
||||
readableAll: true
|
||||
});
|
||||
}, message);
|
||||
|
||||
assert.throws(() => {
|
||||
const server = net.createServer(common.mustNotCall());
|
||||
server.listen({
|
||||
path,
|
||||
writableAll: true
|
||||
});
|
||||
}, message);
|
||||
|
||||
assert.throws(() => {
|
||||
const server = net.createServer(common.mustNotCall());
|
||||
server.listen({
|
||||
path,
|
||||
readableAll: true,
|
||||
writableAll: true
|
||||
});
|
||||
}, message);
|
||||
Reference in new issue
Block a user