Skip to content

Commit 303929b

Browse files
authored
fix int conversion (#1)
fix int conversion
1 parent c5f4c48 commit 303929b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

parser/payload.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"bytes"
66
"fmt"
77
"io"
8+
"math"
89
"strconv"
910
"sync"
1011
)
@@ -115,7 +116,7 @@ func (e *PayloadEncoder) EncodeTo(w io.Writer) error {
115116
return nil
116117
}
117118

118-
//IsString returns true if payload encode to string, otherwise returns false.
119+
// IsString returns true if payload encode to string, otherwise returns false.
119120
func (e *PayloadEncoder) IsString() bool {
120121
return e.isString
121122
}
@@ -166,5 +167,10 @@ func (d *PayloadDecoder) Next() (*PacketDecoder, error) {
166167
if err != nil {
167168
return nil, fmt.Errorf("invalid input")
168169
}
170+
171+
if packetLen > math.MaxInt || packetLen < math.MinInt {
172+
return nil, fmt.Errorf("invalid input")
173+
}
174+
169175
return NewDecoder(newLimitReader(d.r, int(packetLen)))
170176
}

0 commit comments

Comments
 (0)