aboutsummaryrefslogtreecommitdiff
path: root/src/device/device_ledger.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-06-23 15:26:55 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-06-23 15:28:48 +0100
commit41e9cab4e1c9d6df26db1cecd30fe6aafacc80a7 (patch)
tree2b6fda50d0f007b4c55d6a051be0194bb8100a39 /src/device/device_ledger.cpp
parentdevice_ledger: fix potential buffer overflow from bad size calc (diff)
downloadmonero-41e9cab4e1c9d6df26db1cecd30fe6aafacc80a7.tar.xz
device: misc cleanup
use snprintf "just in case" where appropriate consistently use unsigned for temp values pass std::string by const ref rather than by value add length check (which can't happen in practice) for memcpy
Diffstat (limited to '')
-rw-r--r--src/device/device_ledger.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp
index 94cb3db89..8735baeb6 100644
--- a/src/device/device_ledger.cpp
+++ b/src/device/device_ledger.cpp
@@ -187,7 +187,7 @@ namespace hw {
void device_ledger::logCMD() {
if (apdu_verbose) {
char strbuffer[1024];
- sprintf(strbuffer, "%.02x %.02x %.02x %.02x %.02x ",
+ snprintf(strbuffer, sizeof(strbuffer), "%.02x %.02x %.02x %.02x %.02x ",
this->buffer_send[0],
this->buffer_send[1],
this->buffer_send[2],
@@ -203,7 +203,7 @@ namespace hw {
void device_ledger::logRESP() {
if (apdu_verbose) {
char strbuffer[1024];
- sprintf(strbuffer, "%.02x%.02x ",
+ snprintf(strbuffer, sizeof(strbuffer), "%.02x%.02x ",
this->buffer_recv[this->length_recv-2],
this->buffer_recv[this->length_recv-1]
);
@@ -295,7 +295,7 @@ namespace hw {
unsigned int device_ledger::exchange(unsigned int ok, unsigned int mask) {
LONG rv;
- int sw;
+ unsigned int sw;
ASSERT_T0(this->length_send <= BUFFER_SEND_SIZE);
logCMD();