diff --git a/src/darwin_list.cpp b/src/darwin_list.cpp index 8141bc321..5aeaadfdf 100644 --- a/src/darwin_list.cpp +++ b/src/darwin_list.cpp @@ -157,7 +157,7 @@ static stDeviceListItem* GetSerialDevices() { if (result) { stDeviceListItem *deviceListItem = reinterpret_cast( 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)); @@ -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); @@ -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); diff --git a/src/serialport.cpp b/src/serialport.cpp index ebca44961..d6c7ddcb4 100644 --- a/src/serialport.cpp +++ b/src/serialport.cpp @@ -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")); diff --git a/test/serialport.js b/test/serialport.js index 2079f5121..5c2f853bf 100644 --- a/test/serialport.js +++ b/test/serialport.js @@ -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) }); });