aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
authorAlexander Blair <snipa@jagtech.io>2020-01-24 20:07:36 -0800
committerAlexander Blair <snipa@jagtech.io>2020-01-24 20:07:37 -0800
commite51ce477dbbf9f9a194ff117e5040d219f94e483 (patch)
tree629624d86ae76461e684c0043d72b3121838e615 /src/blockchain_db
parentMerge pull request #6154 (diff)
parentdb_lmdb: guard against non NUL terminated keys (diff)
downloadmonero-e51ce477dbbf9f9a194ff117e5040d219f94e483.tar.xz
Merge pull request #6157
402dd207 db_lmdb: guard against non NUL terminated keys (moneromooo-monero)
Diffstat (limited to 'src/blockchain_db')
-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 e8667adcf..6eb5501b7 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;
}
}