aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Winget <tewinget@gmail.com>2014-12-12 18:45:29 -0500
committerwarptangent <warptangent@inbox.com>2015-01-04 19:39:43 -0800
commit5baf9d9eb36d5ec411f4f26b5718b1a2caac8949 (patch)
tree6534ef119c723771c469385751467d773095e98a /src
parentMerge pull request #16 from moneromooo-monero/blockchain (diff)
parentdb_lmdb: do not give the group database write permissions (diff)
downloadmonero-5baf9d9eb36d5ec411f4f26b5718b1a2caac8949.tar.xz
Merge pull request #17 from moneromooo-monero/blockchain
db_lmdb: catch attempt to remove block from an empty blockchain db_lmdb: do not give the group database write permissions
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp
index f53e5bac2..9d0728f6c 100644
--- a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp
+++ b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp
@@ -207,6 +207,9 @@ void BlockchainLMDB::remove_block()
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
+ if (m_height == 0)
+ throw0(BLOCK_DNE ("Attempting to remove block from an empty blockchain"));
+
MDB_val_copy<uint64_t> k(m_height - 1);
MDB_val h;
if (mdb_get(*m_write_txn, m_block_hashes, &k, &h))
@@ -527,7 +530,7 @@ void BlockchainLMDB::open(const std::string& filename)
size_t mapsize = 1LL << 34;
if (auto result = mdb_env_set_mapsize(m_env, mapsize))
throw0(DB_ERROR(std::string("Failed to set max memory map size: ").append(mdb_strerror(result)).c_str()));
- if (auto result = mdb_env_open(m_env, filename.c_str(), 0, 0664))
+ if (auto result = mdb_env_open(m_env, filename.c_str(), 0, 0644))
throw0(DB_ERROR(std::string("Failed to open lmdb environment: ").append(mdb_strerror(result)).c_str()));
// get a read/write MDB_txn