From e813b8c71d3953c0c77e50e877dc4891d1a52de9 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Wed, 23 Nov 2016 18:22:22 -0500 Subject: [PATCH] counter: fix tx buffer overflow --- example/counter/counter.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/example/counter/counter.go b/example/counter/counter.go index 230556e18..ef57d8407 100644 --- a/example/counter/counter.go +++ b/example/counter/counter.go @@ -30,6 +30,9 @@ func (app *CounterApplication) SetOption(key string, value string) (log string) func (app *CounterApplication) AppendTx(tx []byte) types.Result { if app.serial { + if len(tx) > 8 { + return types.ErrEncodingError.SetLog(Fmt("Max tx size is 8 bytes, got %d", len(tx))) + } tx8 := make([]byte, 8) copy(tx8[len(tx8)-len(tx):], tx) txValue := binary.BigEndian.Uint64(tx8) @@ -43,6 +46,9 @@ func (app *CounterApplication) AppendTx(tx []byte) types.Result { func (app *CounterApplication) CheckTx(tx []byte) types.Result { if app.serial { + if len(tx) > 8 { + return types.ErrEncodingError.SetLog(Fmt("Max tx size is 8 bytes, got %d", len(tx))) + } tx8 := make([]byte, 8) copy(tx8[len(tx8)-len(tx):], tx) txValue := binary.BigEndian.Uint64(tx8)