Skip to content

Commit

Permalink
fix: a few warnings and deprecations (#1558)
Browse files Browse the repository at this point in the history
- c++ string copies were potentially insecure
- sandboxes are now made differently
  • Loading branch information
reconbot committed Apr 29, 2018
1 parent e1998b3 commit a250f09
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/darwin_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static stDeviceListItem* GetSerialDevices() {
if (result) {
stDeviceListItem *deviceListItem = reinterpret_cast<stDeviceListItem*>( malloc(sizeof(stDeviceListItem)));
stSerialDevice *serialDevice = &(deviceListItem->value);
snprintf(serialDevice->port, sizeof(serialDevice->port), bsdPath);
snprintf(serialDevice->port, sizeof(serialDevice->port), "%s", bsdPath);
memset(serialDevice->locationId, 0, sizeof(serialDevice->locationId));
memset(serialDevice->vendorId, 0, sizeof(serialDevice->vendorId));
memset(serialDevice->productId, 0, sizeof(serialDevice->productId));
Expand Down Expand Up @@ -199,7 +199,7 @@ static stDeviceListItem* GetSerialDevices() {
kCFStringEncodingUTF8);

if (result) {
snprintf(serialDevice->manufacturer, sizeof(serialDevice->manufacturer), manufacturer);
snprintf(serialDevice->manufacturer, sizeof(serialDevice->manufacturer), "%s", manufacturer);
}

CFRelease(manufacturerAsCFString);
Expand All @@ -222,7 +222,7 @@ static stDeviceListItem* GetSerialDevices() {
kCFStringEncodingUTF8);

if (result) {
snprintf(serialDevice->serialNumber, sizeof(serialDevice->serialNumber), serialNumber);
snprintf(serialDevice->serialNumber, sizeof(serialDevice->serialNumber), "%s", serialNumber);
}

CFRelease(serialNumberAsCFString);
Expand Down
2 changes: 1 addition & 1 deletion src/serialport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ NAN_METHOD(Open) {
}

OpenBaton* baton = new OpenBaton();
snprintf(baton->path, sizeof(baton->path), *path);
snprintf(baton->path, sizeof(baton->path), "%s", *path);
baton->baudRate = getIntFromObject(options, "baudRate");
baton->dataBits = getIntFromObject(options, "dataBits");
baton->parity = ToParityEnum(getStringFromObj(options, "parity"));
Expand Down
2 changes: 1 addition & 1 deletion test/serialport.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('SerialPort', () => {

beforeEach(() => {
SerialPort.Binding = mockBinding;
sandbox = sinon.sandbox.create();
sandbox = sinon.createSandbox();
mockBinding.createPort('/dev/exists', { echo: true, readyData: new Buffer(0) });
});

Expand Down

0 comments on commit a250f09

Please sign in to comment.