diff --git a/lib/net.js b/lib/net.js index ada94e02f80c67..ba90028a3a8172 100644 --- a/lib/net.js +++ b/lib/net.js @@ -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, diff --git a/test/parallel/test-pipe-abstract-socket.js b/test/parallel/test-pipe-abstract-socket.js new file mode 100644 index 00000000000000..baf76d6b82cf59 --- /dev/null +++ b/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);