Skip to content

Commit

Permalink
net: check pipe mode and path
Browse files Browse the repository at this point in the history
PR-URL: #50770
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
theanarkh authored and UlisesGascon committed Dec 19, 2023
1 parent 932a5d7 commit f808e7a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/net.js
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
@@ -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);

0 comments on commit f808e7a

Please sign in to comment.