Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: check pipe mode and path #50770

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
34 changes: 34 additions & 0 deletions test/parallel/test-pipe-abstract-socket.js
Original file line number Diff line number Diff line change
@@ -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);
Loading