Skip to content

Commit 9197b0f

Browse files
theanarkhRafaelGSS
authored andcommitted
net: check pipe mode and path
PR-URL: #50770 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 221f02d commit 9197b0f

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎lib/net.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,12 @@ Server.prototype.listen = function(...args) {
20142014
// (path[, backlog][, cb]) or (options[, cb])
20152015
// where path or options.path is a UNIX domain socket or Windows pipe
20162016
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+
constmsg='can not set readableAll or writableAllt to true when path is abstract unix socket';
2021+
thrownewERR_INVALID_ARG_VALUE('options',options,msg);
2022+
}
20172023
constpipeName=this._pipeName=options.path;
20182024
backlog=options.backlog||backlogFromArgs;
20192025
listenInCluster(this,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
constcommon=require('../common');
3+
constassert=require('assert');
4+
constnet=require('net');
5+
6+
if(!common.isLinux)common.skip();
7+
8+
constpath='\0abstract';
9+
constmessage=/cannotsetreadableAllorwritableAllttotruewhenpathisabstractunixsocket/;
10+
11+
assert.throws(()=>{
12+
constserver=net.createServer(common.mustNotCall());
13+
server.listen({
14+
path,
15+
readableAll: true
16+
});
17+
},message);
18+
19+
assert.throws(()=>{
20+
constserver=net.createServer(common.mustNotCall());
21+
server.listen({
22+
path,
23+
writableAll: true
24+
});
25+
},message);
26+
27+
assert.throws(()=>{
28+
constserver=net.createServer(common.mustNotCall());
29+
server.listen({
30+
path,
31+
readableAll: true,
32+
writableAll: true
33+
});
34+
},message);

0 commit comments

Comments
 (0)