From ac5ccc5030045ab17251a8987491f8996c43451f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AA=E0=AE=BE=E0=AE=B2=E0=AE=BE=E0=AE=9C=E0=AE=BF?= Date: Thu, 9 Jul 2020 10:32:12 +0530 Subject: [PATCH 1/2] add assert to check integer overflow for table size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: பாலாஜி --- table/builder.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/table/builder.go b/table/builder.go index 50ba15356..a1364fcd3 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) } From bc5f8ddb63a66744cd8ce0874190aa6e15554370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AA=E0=AE=BE=E0=AE=B2=E0=AE=BE=E0=AE=9C=E0=AE=BF?= Date: Thu, 9 Jul 2020 10:34:02 +0530 Subject: [PATCH 2/2] minor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: பாலாஜி --- table/builder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/table/builder.go b/table/builder.go index a1364fcd3..6a6f194ec 100644 --- a/table/builder.go +++ b/table/builder.go @@ -328,7 +328,7 @@ func (b *Builder) shouldFinishBlock(key []byte, value y.ValueStruct) bool { estimatedSize += aes.BlockSize } // Integer overflow check for table size. - y.AssertTrue(uint64(b.sz)+uint64(estimatedSize) > math.MaxUint32) + y.AssertTrue(uint64(b.sz)+uint64(estimatedSize) < math.MaxUint32) return estimatedSize > uint32(b.opt.BlockSize) }