diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-11-18 12:35:11 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-11-19 11:12:49 +0000 |
commit | 402dd2078cc8ecb83564c7ee494dad0feb11b9df (patch) | |
tree | 0a86b81acec601da0b278c3bae1220af8e2fd6df | |
parent | Merge pull request #6097 (diff) | |
download | monero-402dd2078cc8ecb83564c7ee494dad0feb11b9df.tar.xz |
db_lmdb: guard against non NUL terminated keys
-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 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; } } |