susumu.yata
null+****@clear*****
Thu May 30 15:08:02 JST 2013
susumu.yata 2013-05-30 15:08:02 +0900 (Thu, 30 May 2013) New Revision: 06173e12f6a7e3b55bb56a6e8d774e626ccc420b https://github.com/groonga/grnxx/commit/06173e12f6a7e3b55bb56a6e8d774e626ccc420b Message: Check whether or not page_id exceeds the upper limit. Modified files: lib/grnxx/map/bytes_store.cpp lib/grnxx/map/bytes_store.hpp Modified: lib/grnxx/map/bytes_store.cpp (+8 -1) =================================================================== --- lib/grnxx/map/bytes_store.cpp 2013-05-30 14:47:31 +0900 (57159d1) +++ lib/grnxx/map/bytes_store.cpp 2013-05-30 15:08:02 +0900 (df04d34) @@ -44,8 +44,10 @@ constexpr uint32_t BYTES_STORE_PAGE_SIZE = 1U << 20; constexpr uint32_t BYTES_STORE_TABLE_SIZE = 1U << 14; constexpr uint32_t BYTES_STORE_SECONDARY_TABLE_SIZE = 1U << 14; +constexpr uint32_t BYTES_STORE_MAX_PAGE_ID = + (BYTES_STORE_TABLE_SIZE * BYTES_STORE_SECONDARY_TABLE_SIZE) - 1; constexpr uint32_t BYTES_STORE_INVALID_PAGE_ID = - BYTES_STORE_TABLE_SIZE * BYTES_STORE_SECONDARY_TABLE_SIZE; + BYTES_STORE_MAX_PAGE_ID + 1; enum BytesStorePageStatus : uint32_t { // The next byte sequence will be added to the page. @@ -444,6 +446,11 @@ bool BytesStoreImpl::reserve_active_page(uint32_t *page_id, } else { // Create a new page. next_page_id = header_->max_page_id + 1; + if (next_page_id > BYTES_STORE_MAX_PAGE_ID) { + GRNXX_ERROR() << "too many pages: next_page_id = " << next_page_id + << ", max_page_id = " << BYTES_STORE_MAX_PAGE_ID; + return false; + } } BytesStorePageHeader * const next_page_header = page_headers_->get_pointer(next_page_id); Modified: lib/grnxx/map/bytes_store.hpp (+1 -2) =================================================================== --- lib/grnxx/map/bytes_store.hpp 2013-05-30 14:47:31 +0900 (c648d85) +++ lib/grnxx/map/bytes_store.hpp 2013-05-30 15:08:02 +0900 (5ef0d79) @@ -32,8 +32,7 @@ class Storage; namespace map { -// TODO: Fix this value. -constexpr uint64_t BYTES_STORE_INVALID_BYTES_ID = 1ULL << 62; +constexpr uint64_t BYTES_STORE_INVALID_BYTES_ID = 1ULL << 61; class BytesStore { public: -------------- next part -------------- HTML����������������������������... Download