device_ledger: add paranoid buffer overflow check

Coverity 200183
This commit is contained in:
moneromooo-monero 2019-07-03 13:49:59 +00:00
parent cdfa2e58df
commit 7c894fc7fd
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -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;