Skip to content

Commit

Permalink
memtx: fix integer overflow in memtx index statistics
Browse files Browse the repository at this point in the history
This may result in invalid statistics if there's more than 4 GB
allocated for index extents.

Fixes commit a75f4b7 ("memtx: introduce read view statistics").
Follow-up tarantool#8501
Coverity report 1537026, 1537027.

NO_DOC=bug fix
NO_CHANGELOG=unreleased
NO_TEST=complicated; checked by coverity
  • Loading branch information
locker committed Apr 6, 2023
1 parent 2970bd5 commit b1fcd8a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/box/memtx_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1523,9 +1523,10 @@ memtx_engine_stat_index(struct memtx_engine *memtx, struct info_handler *h)
{
struct matras_stats *stats = &memtx->index_extent_stats;
info_table_begin(h, "index");
info_append_int(h, "total", stats->extent_count * MEMTX_EXTENT_SIZE);
info_append_int(h, "read_view",
stats->read_view_extent_count * MEMTX_EXTENT_SIZE);
info_append_int(h, "total", (size_t)stats->extent_count *
MEMTX_EXTENT_SIZE);
info_append_int(h, "read_view", (size_t)stats->read_view_extent_count *
MEMTX_EXTENT_SIZE);
info_table_end(h); /* index */
}

Expand Down

0 comments on commit b1fcd8a

Please sign in to comment.