diff options
author | Austin Schuh <austin@peloton-tech.com> | 2015-08-21 14:16:34 -0700 |
---|---|---|
committer | Austin Schuh <austin@peloton-tech.com> | 2015-08-28 11:10:55 -0700 |
commit | ad1d726cc28e783495e7d11c73c49a7502400a89 (patch) | |
tree | 268a504f43429bcec615ca490440c991e3719f61 /src | |
parent | fb0af6d02eab821891fb245ea5a4fe9f1f2ac01d (diff) | |
download | protobuf-ad1d726cc28e783495e7d11c73c49a7502400a89.tar.gz protobuf-ad1d726cc28e783495e7d11c73c49a7502400a89.tar.bz2 protobuf-ad1d726cc28e783495e7d11c73c49a7502400a89.zip |
Handled blocks being too small in arena.cc
When the user passed in a block which was smaller than the Block
structure, this code would blow past the end of the memory and
crash. Check for that condition.
Diffstat (limited to 'src')
-rwxr-xr-x | src/google/protobuf/arena.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index ed1c5ef2..f499108d 100755 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -61,6 +61,9 @@ void Arena::Init() { cleanup_list_ = 0; if (options_.initial_block != NULL && options_.initial_block_size > 0) { + GOOGLE_CHECK_GE(options_.initial_block_size, sizeof(Block)) + << ": Initial block size too small for header."; + // Add first unowned block to list. Block* first_block = reinterpret_cast<Block*>(options_.initial_block); first_block->size = options_.initial_block_size; |