GeezerVison is showing github.com — net: check pipe mode and path · nodejs/node@f808e7a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/net.js +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2014,6 +2014,12 @@ Server.prototype.listen = function(...args) { |
2014 | 2014 | // (path[, backlog][, cb]) or (options[, cb]) |
2015 | 2015 | // where path or options.path is a UNIX domain socket or Windows pipe |
2016 | 2016 | 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 | + } |
2017 | 2023 | const pipeName = this._pipeName = options.path; |
2018 | 2024 | backlog = options.backlog || backlogFromArgs; |
2019 | 2025 | listenInCluster(this, |
|
Collapse file
Copy file name to clipboard +34Lines changed: 34 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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); |