aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-29 08:17:32 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-06-14 08:47:29 +0000
commit0564da5fdc165948ba7c862fb81478f9287a072d (patch)
tree3a30a0c1ec0c5a8d8fa73b950c7251aa219d1e09 /src
parentabstract_tcp_server2: improve DoS resistance (diff)
downloadmonero-0564da5fdc165948ba7c862fb81478f9287a072d.tar.xz
ensure no NULL is passed to memcpy
NULL is valid when size is 0, but memcpy uses nonnull attributes, so let's not poke the bear
Diffstat (limited to 'src')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp4
-rw-r--r--src/crypto/keccak.c3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index a03a0989b..f05eb0f30 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -1077,11 +1077,11 @@ void BlockchainLMDB::add_tx_amount_output_indices(const uint64_t tx_id,
int result = 0;
- int num_outputs = amount_output_indices.size();
+ size_t num_outputs = amount_output_indices.size();
MDB_val_set(k_tx_id, tx_id);
MDB_val v;
- v.mv_data = (void *)amount_output_indices.data();
+ v.mv_data = num_outputs ? (void *)amount_output_indices.data() : (void*)"";
v.mv_size = sizeof(uint64_t) * num_outputs;
// LOG_PRINT_L1("tx_outputs[tx_hash] size: " << v.mv_size);
diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c
index 170911262..18ed3152f 100644
--- a/src/crypto/keccak.c
+++ b/src/crypto/keccak.c
@@ -116,7 +116,8 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen)
local_abort("Bad keccak use");
}
- memcpy(temp, in, inlen);
+ if (inlen > 0)
+ memcpy(temp, in, inlen);
temp[inlen++] = 1;
memset(temp + inlen, 0, rsiz - inlen);
temp[rsiz - 1] |= 0x80;