From 7f4e4b560aabb5521f3591972ab5fdc1aec6801b Mon Sep 17 00:00:00 2001 From: Balaji Jinnah Date: Fri, 10 Jul 2020 10:06:07 +0530 Subject: [PATCH] add assert to check integer overflow for table size (#1402) --- table/builder.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/table/builder.go b/table/builder.go index 50ba15356..6a6f194ec 100644 --- a/table/builder.go +++ b/table/builder.go @@ -327,6 +327,9 @@ func (b *Builder) shouldFinishBlock(key []byte, value y.ValueStruct) bool { // So, size of IV is added to estimatedSize. estimatedSize += aes.BlockSize } + // Integer overflow check for table size. + y.AssertTrue(uint64(b.sz)+uint64(estimatedSize) < math.MaxUint32) + return estimatedSize > uint32(b.opt.BlockSize) }