diff options
author | Alexander Blair <snipa@jagtech.io> | 2020-01-24 20:07:36 -0800 |
---|---|---|
committer | Alexander Blair <snipa@jagtech.io> | 2020-01-24 20:07:37 -0800 |
commit | e51ce477dbbf9f9a194ff117e5040d219f94e483 (patch) | |
tree | 629624d86ae76461e684c0043d72b3121838e615 /src/blockchain_db | |
parent | Merge pull request #6154 (diff) | |
parent | db_lmdb: guard against non NUL terminated keys (diff) | |
download | monero-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.cpp | 10 |
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; } } |