aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/lmdb/db_lmdb.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-11-18 12:35:11 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-11-19 11:12:49 +0000
commit402dd2078cc8ecb83564c7ee494dad0feb11b9df (patch)
tree0a86b81acec601da0b278c3bae1220af8e2fd6df /src/blockchain_db/lmdb/db_lmdb.cpp
parentMerge pull request #6097 (diff)
downloadmonero-402dd2078cc8ecb83564c7ee494dad0feb11b9df.tar.xz
db_lmdb: guard against non NUL terminated keys
Diffstat (limited to 'src/blockchain_db/lmdb/db_lmdb.cpp')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index f978ef307..f46e53f3d 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -163,7 +163,15 @@ int BlockchainLMDB::compare_string(const MDB_val *a, const MDB_val *b)
{
const char *va = (const char*) a->mv_data;
const char *vb = (const char*) b->mv_data;
- return strcmp(va, vb);
+ const size_t sz = std::min(a->mv_size, b->mv_size);
+ int ret = strncmp(va, vb, sz);
+ if (ret)
+ return ret;
+ if (a->mv_size < b->mv_size)
+ return -1;
+ if (a->mv_size > b->mv_size)
+ return 1;
+ return 0;
}
}