Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes arbitrary command injection by using execFile instead of exec #18

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
@@ -1,4 +1,7 @@
language: node_js
os:
- linux
- osx
node_js:
- stable
- "0.12"
Expand Down
6 changes: 3 additions & 3 deletions lib/linux.js
@@ -1,11 +1,11 @@
var exec = require('child_process').exec;
var execFile = require('child_process').execFile;

module.exports = function (iface, callback) {
exec("cat /sys/class/net/" + iface + "/address", function (err, out) {
execFile("cat", ["/sys/class/net/" + iface + "/address"], function (err, out) {
if (err) {
callback(err, null);
return;
}
callback(null, out.trim().toLowerCase());
});
};
};
16 changes: 0 additions & 16 deletions lib/macosx.js

This file was deleted.

4 changes: 2 additions & 2 deletions lib/unix.js
@@ -1,7 +1,7 @@
var exec = require('child_process').exec;
var execFile = require('child_process').execFile;

module.exports = function (iface, callback) {
exec("ifconfig " + iface, function (err, out) {
execFile("ifconfig", [iface], function (err, out) {
if (err) {
callback(err, null);
return;
Expand Down
4 changes: 2 additions & 2 deletions lib/windows.js
@@ -1,4 +1,4 @@
var exec = require('child_process').exec;
var execFile = require('child_process').execFile;

var regexRegex = /[-\/\\^$*+?.()|[\]{}]/g;

Expand All @@ -7,7 +7,7 @@ function escape(string) {
}

module.exports = function (iface, callback) {
exec("ipconfig /all", function (err, out) {
execFile("ipconfig", ["/all"], function (err, out) {
if (err) {
callback(err, null);
return;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "macaddress",
"version": "0.2.9",
"version": "0.2.10",
"description": "Get the MAC addresses (hardware addresses) of the hosts network interfaces.",
"main": "index.js",
"scripts": {
Expand Down