Skip to content

Commit

Permalink
fix a vulnerability issue if a provided port is not a number
Browse files Browse the repository at this point in the history
  • Loading branch information
ssnau committed Mar 17, 2021
1 parent 5268f23 commit bec8e37
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var notEmpty = function(x) {return x};

module.exports = function killport(port) {
return (new Promise(function(resolve, reject) {
if (!/^\d+$/.test(port)) throw new Error('port must be a number.');
var cmd = 'lsof -i:' + port;
cp.exec(cmd, function(err, stdout, stderr){
// do not check `err`, if no process found
Expand Down

0 comments on commit bec8e37

Please sign in to comment.