From 7c894fc7fd1bcccbb9850ad1088c0f0ac006c427 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 3 Jul 2019 13:49:59 +0000 Subject: device_ledger: add paranoid buffer overflow check Coverity 200183 --- src/device/device_ledger.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/device') diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp index eba633da8..2d91b881b 100644 --- a/src/device/device_ledger.cpp +++ b/src/device/device_ledger.cpp @@ -320,7 +320,9 @@ namespace hw { bool device_ledger::reset() { reset_buffer(); int offset = set_command_header_noopt(INS_RESET); - memmove(this->buffer_send+offset, MONERO_VERSION, strlen(MONERO_VERSION)); + const size_t verlen = strlen(MONERO_VERSION); + ASSERT_X(offset + verlen <= BUFFER_SEND_SIZE, "MONERO_VERSION is too long") + memmove(this->buffer_send+offset, MONERO_VERSION, verlen); offset += strlen(MONERO_VERSION); this->buffer_send[4] = offset-5; this->length_send = offset; -- cgit v1.2.3