Commit 2cd55b6f authored by Kirill Smelkov's avatar Kirill Smelkov

X dumb way to check for decode overflow

parent 47999e52
...@@ -32,6 +32,9 @@ func (p *Address) NEOEncode(data []byte) { ...@@ -32,6 +32,9 @@ func (p *Address) NEOEncode(data []byte) {
func (p *Address) NEODecode(data []byte) (int, error) { func (p *Address) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -41,6 +44,9 @@ func (p *Address) NEODecode(data []byte) (int, error) { ...@@ -41,6 +44,9 @@ func (p *Address) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 4 + l nread += 4 + l
} }
if len(data) < 2 {
goto overflow
}
p.Port = binary.BigEndian.Uint16(data[0:]) p.Port = binary.BigEndian.Uint16(data[0:])
return int(nread) + 2, nil return int(nread) + 2, nil
...@@ -77,8 +83,14 @@ func (p *NodeInfo) NEOEncode(data []byte) { ...@@ -77,8 +83,14 @@ func (p *NodeInfo) NEOEncode(data []byte) {
func (p *NodeInfo) NEODecode(data []byte) (int, error) { func (p *NodeInfo) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:]))) p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:])))
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -88,9 +100,21 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) { ...@@ -88,9 +100,21 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 8 + l nread += 8 + l
} }
if len(data) < 2 {
goto overflow
}
p.Address.Port = binary.BigEndian.Uint16(data[0:]) p.Address.Port = binary.BigEndian.Uint16(data[0:])
if len(data) < 6 {
goto overflow
}
p.UUID = UUID(int32(binary.BigEndian.Uint32(data[2:]))) p.UUID = UUID(int32(binary.BigEndian.Uint32(data[2:])))
if len(data) < 10 {
goto overflow
}
p.NodeState = NodeState(int32(binary.BigEndian.Uint32(data[6:]))) p.NodeState = NodeState(int32(binary.BigEndian.Uint32(data[6:])))
if len(data) < 18 {
goto overflow
}
p.IdTimestamp = float64_NEODecode(data[10:]) p.IdTimestamp = float64_NEODecode(data[10:])
return int(nread) + 18, nil return int(nread) + 18, nil
...@@ -113,7 +137,13 @@ func (p *CellInfo) NEOEncode(data []byte) { ...@@ -113,7 +137,13 @@ func (p *CellInfo) NEOEncode(data []byte) {
func (p *CellInfo) NEODecode(data []byte) (int, error) { func (p *CellInfo) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.UUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) p.UUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
if len(data) < 8 {
goto overflow
}
p.CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) p.CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -151,15 +181,27 @@ func (p *RowInfo) NEOEncode(data []byte) { ...@@ -151,15 +181,27 @@ func (p *RowInfo) NEOEncode(data []byte) {
func (p *RowInfo) NEODecode(data []byte) (int, error) { func (p *RowInfo) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.Offset = binary.BigEndian.Uint32(data[0:]) p.Offset = binary.BigEndian.Uint32(data[0:])
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread += 8
p.CellList = make([]CellInfo, l) p.CellList = make([]CellInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
if len(data) < 4 {
goto overflow
}
(*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
if len(data) < 8 {
goto overflow
}
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -196,6 +238,9 @@ func (p *Notify) NEOEncode(data []byte) { ...@@ -196,6 +238,9 @@ func (p *Notify) NEOEncode(data []byte) {
func (p *Notify) NEODecode(data []byte) (int, error) { func (p *Notify) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -236,8 +281,14 @@ func (p *Error) NEOEncode(data []byte) { ...@@ -236,8 +281,14 @@ func (p *Error) NEOEncode(data []byte) {
func (p *Error) NEODecode(data []byte) (int, error) { func (p *Error) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.Code = binary.BigEndian.Uint32(data[0:]) p.Code = binary.BigEndian.Uint32(data[0:])
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -331,10 +382,22 @@ func (p *RequestIdentification) NEOEncode(data []byte) { ...@@ -331,10 +382,22 @@ func (p *RequestIdentification) NEOEncode(data []byte) {
func (p *RequestIdentification) NEODecode(data []byte) (int, error) { func (p *RequestIdentification) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.ProtocolVersion = binary.BigEndian.Uint32(data[0:]) p.ProtocolVersion = binary.BigEndian.Uint32(data[0:])
if len(data) < 8 {
goto overflow
}
p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[4:]))) p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[4:])))
if len(data) < 12 {
goto overflow
}
p.UUID = UUID(int32(binary.BigEndian.Uint32(data[8:]))) p.UUID = UUID(int32(binary.BigEndian.Uint32(data[8:])))
{ {
if len(data) < 16 {
goto overflow
}
l := binary.BigEndian.Uint32(data[12:]) l := binary.BigEndian.Uint32(data[12:])
data = data[16:] data = data[16:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -344,8 +407,14 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) { ...@@ -344,8 +407,14 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 16 + l nread += 16 + l
} }
if len(data) < 2 {
goto overflow
}
p.Address.Port = binary.BigEndian.Uint16(data[0:]) p.Address.Port = binary.BigEndian.Uint16(data[0:])
{ {
if len(data) < 6 {
goto overflow
}
l := binary.BigEndian.Uint32(data[2:]) l := binary.BigEndian.Uint32(data[2:])
data = data[6:] data = data[6:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -355,6 +424,9 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) { ...@@ -355,6 +424,9 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 6 + l nread += 6 + l
} }
if len(data) < 8 {
goto overflow
}
p.IdTimestamp = float64_NEODecode(data[0:]) p.IdTimestamp = float64_NEODecode(data[0:])
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -423,12 +495,30 @@ func (p *AcceptIdentification) NEOEncode(data []byte) { ...@@ -423,12 +495,30 @@ func (p *AcceptIdentification) NEOEncode(data []byte) {
func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:]))) p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:])))
if len(data) < 8 {
goto overflow
}
p.MyUUID = UUID(int32(binary.BigEndian.Uint32(data[4:]))) p.MyUUID = UUID(int32(binary.BigEndian.Uint32(data[4:])))
if len(data) < 12 {
goto overflow
}
p.NumPartitions = binary.BigEndian.Uint32(data[8:]) p.NumPartitions = binary.BigEndian.Uint32(data[8:])
if len(data) < 16 {
goto overflow
}
p.NumReplicas = binary.BigEndian.Uint32(data[12:]) p.NumReplicas = binary.BigEndian.Uint32(data[12:])
if len(data) < 20 {
goto overflow
}
p.YourUUID = UUID(int32(binary.BigEndian.Uint32(data[16:]))) p.YourUUID = UUID(int32(binary.BigEndian.Uint32(data[16:])))
{ {
if len(data) < 24 {
goto overflow
}
l := binary.BigEndian.Uint32(data[20:]) l := binary.BigEndian.Uint32(data[20:])
data = data[24:] data = data[24:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -438,8 +528,14 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -438,8 +528,14 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 24 + l nread += 24 + l
} }
if len(data) < 2 {
goto overflow
}
p.Primary.Port = binary.BigEndian.Uint16(data[0:]) p.Primary.Port = binary.BigEndian.Uint16(data[0:])
{ {
if len(data) < 6 {
goto overflow
}
l := binary.BigEndian.Uint32(data[2:]) l := binary.BigEndian.Uint32(data[2:])
data = data[6:] data = data[6:]
nread += 6 nread += 6
...@@ -450,6 +546,9 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -450,6 +546,9 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.KnownMasterList[i] a := &p.KnownMasterList[i]
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -459,7 +558,13 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -459,7 +558,13 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 4 + l nread += 4 + l
} }
if len(data) < 2 {
goto overflow
}
(*a).Address.Port = binary.BigEndian.Uint16(data[0:]) (*a).Address.Port = binary.BigEndian.Uint16(data[0:])
if len(data) < 6 {
goto overflow
}
(*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[2:]))) (*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[2:])))
data = data[6:] data = data[6:]
nread += 6 nread += 6
...@@ -504,6 +609,9 @@ func (p *AnswerPrimary) NEOEncode(data []byte) { ...@@ -504,6 +609,9 @@ func (p *AnswerPrimary) NEOEncode(data []byte) {
func (p *AnswerPrimary) NEODecode(data []byte) (int, error) { func (p *AnswerPrimary) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.PrimaryUUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) p.PrimaryUUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return int(nread) + 4, nil
...@@ -584,8 +692,17 @@ func (p *AnswerRecovery) NEOEncode(data []byte) { ...@@ -584,8 +692,17 @@ func (p *AnswerRecovery) NEOEncode(data []byte) {
func (p *AnswerRecovery) NEODecode(data []byte) (int, error) { func (p *AnswerRecovery) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.PTid = PTid(binary.BigEndian.Uint64(data[0:])) p.PTid = PTid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.BackupTID = Tid(binary.BigEndian.Uint64(data[8:])) p.BackupTID = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 24 {
goto overflow
}
p.TruncateTID = Tid(binary.BigEndian.Uint64(data[16:])) p.TruncateTID = Tid(binary.BigEndian.Uint64(data[16:]))
return int(nread) + 24, nil return int(nread) + 24, nil
...@@ -627,7 +744,13 @@ func (p *AnswerLastIDs) NEOEncode(data []byte) { ...@@ -627,7 +744,13 @@ func (p *AnswerLastIDs) NEOEncode(data []byte) {
func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) { func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.LastOID = Oid(binary.BigEndian.Uint64(data[0:])) p.LastOID = Oid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.LastTID = Tid(binary.BigEndian.Uint64(data[8:])) p.LastTID = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return int(nread) + 16, nil
...@@ -703,23 +826,41 @@ func (p *AnswerPartitionTable) NEOEncode(data []byte) { ...@@ -703,23 +826,41 @@ func (p *AnswerPartitionTable) NEOEncode(data []byte) {
func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) { func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.PTid = PTid(binary.BigEndian.Uint64(data[0:])) p.PTid = PTid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread += 12
p.RowList = make([]RowInfo, l) p.RowList = make([]RowInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
if len(data) < 4 {
goto overflow
}
(*a).Offset = binary.BigEndian.Uint32(data[0:]) (*a).Offset = binary.BigEndian.Uint32(data[0:])
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread += 8
(*a).CellList = make([]CellInfo, l) (*a).CellList = make([]CellInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
if len(data) < 4 {
goto overflow
}
(*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
if len(data) < 8 {
goto overflow
}
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -784,23 +925,41 @@ func (p *NotifyPartitionTable) NEOEncode(data []byte) { ...@@ -784,23 +925,41 @@ func (p *NotifyPartitionTable) NEOEncode(data []byte) {
func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) { func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.PTid = PTid(binary.BigEndian.Uint64(data[0:])) p.PTid = PTid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread += 12
p.RowList = make([]RowInfo, l) p.RowList = make([]RowInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
if len(data) < 4 {
goto overflow
}
(*a).Offset = binary.BigEndian.Uint32(data[0:]) (*a).Offset = binary.BigEndian.Uint32(data[0:])
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread += 8
(*a).CellList = make([]CellInfo, l) (*a).CellList = make([]CellInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
if len(data) < 4 {
goto overflow
}
(*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
if len(data) < 8 {
goto overflow
}
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -847,8 +1006,14 @@ func (p *PartitionChanges) NEOEncode(data []byte) { ...@@ -847,8 +1006,14 @@ func (p *PartitionChanges) NEOEncode(data []byte) {
func (p *PartitionChanges) NEODecode(data []byte) (int, error) { func (p *PartitionChanges) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.PTid = PTid(binary.BigEndian.Uint64(data[0:])) p.PTid = PTid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread += 12
...@@ -859,8 +1024,17 @@ func (p *PartitionChanges) NEODecode(data []byte) (int, error) { ...@@ -859,8 +1024,17 @@ func (p *PartitionChanges) NEODecode(data []byte) (int, error) {
}, l) }, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
if len(data) < 4 {
goto overflow
}
(*a).Offset = binary.BigEndian.Uint32(data[0:]) (*a).Offset = binary.BigEndian.Uint32(data[0:])
if len(data) < 8 {
goto overflow
}
(*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[4:]))) (*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[4:])))
if len(data) < 12 {
goto overflow
}
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[8:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[8:])))
data = data[12:] data = data[12:]
nread += 12 nread += 12
...@@ -886,6 +1060,9 @@ func (p *StartOperation) NEOEncode(data []byte) { ...@@ -886,6 +1060,9 @@ func (p *StartOperation) NEOEncode(data []byte) {
func (p *StartOperation) NEODecode(data []byte) (int, error) { func (p *StartOperation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 1 {
goto overflow
}
p.Backup = byte2bool((data[0:])[0]) p.Backup = byte2bool((data[0:])[0])
return int(nread) + 1, nil return int(nread) + 1, nil
...@@ -960,14 +1137,23 @@ func (p *AnswerUnfinishedTransactions) NEOEncode(data []byte) { ...@@ -960,14 +1137,23 @@ func (p *AnswerUnfinishedTransactions) NEOEncode(data []byte) {
func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) { func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.MaxTID = Tid(binary.BigEndian.Uint64(data[0:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread += 12
p.TidList = make([]struct{ UnfinishedTID Tid }, l) p.TidList = make([]struct{ UnfinishedTID Tid }, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.TidList[i] a := &p.TidList[i]
if len(data) < 8 {
goto overflow
}
(*a).UnfinishedTID = Tid(binary.BigEndian.Uint64(data[0:])) (*a).UnfinishedTID = Tid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -1033,13 +1219,22 @@ func (p *AnswerLockedTransactions) NEOEncode(data []byte) { ...@@ -1033,13 +1219,22 @@ func (p *AnswerLockedTransactions) NEOEncode(data []byte) {
func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) { func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.TidDict = make(map[Tid]Tid, l) p.TidDict = make(map[Tid]Tid, l)
m := p.TidDict m := p.TidDict
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
if len(data) < 8 {
goto overflow
}
key := Tid(binary.BigEndian.Uint64(data[0:])) key := Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
m[key] = Tid(binary.BigEndian.Uint64(data[8:])) m[key] = Tid(binary.BigEndian.Uint64(data[8:]))
data = data[16:] data = data[16:]
nread += 16 nread += 16
...@@ -1065,6 +1260,9 @@ func (p *FinalTID) NEOEncode(data []byte) { ...@@ -1065,6 +1260,9 @@ func (p *FinalTID) NEOEncode(data []byte) {
func (p *FinalTID) NEODecode(data []byte) (int, error) { func (p *FinalTID) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -1086,6 +1284,9 @@ func (p *AnswerFinalTID) NEOEncode(data []byte) { ...@@ -1086,6 +1284,9 @@ func (p *AnswerFinalTID) NEOEncode(data []byte) {
func (p *AnswerFinalTID) NEODecode(data []byte) (int, error) { func (p *AnswerFinalTID) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -1108,7 +1309,13 @@ func (p *ValidateTransaction) NEOEncode(data []byte) { ...@@ -1108,7 +1309,13 @@ func (p *ValidateTransaction) NEOEncode(data []byte) {
func (p *ValidateTransaction) NEODecode(data []byte) (int, error) { func (p *ValidateTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[8:])) p.Tid = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return int(nread) + 16, nil
...@@ -1130,6 +1337,9 @@ func (p *BeginTransaction) NEOEncode(data []byte) { ...@@ -1130,6 +1337,9 @@ func (p *BeginTransaction) NEOEncode(data []byte) {
func (p *BeginTransaction) NEODecode(data []byte) (int, error) { func (p *BeginTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -1151,6 +1361,9 @@ func (p *AnswerBeginTransaction) NEOEncode(data []byte) { ...@@ -1151,6 +1361,9 @@ func (p *AnswerBeginTransaction) NEOEncode(data []byte) {
func (p *AnswerBeginTransaction) NEODecode(data []byte) (int, error) { func (p *AnswerBeginTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -1202,26 +1415,41 @@ func (p *FinishTransaction) NEOEncode(data []byte) { ...@@ -1202,26 +1415,41 @@ func (p *FinishTransaction) NEOEncode(data []byte) {
func (p *FinishTransaction) NEODecode(data []byte) (int, error) { func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread += 12
p.OIDList = make([]Oid, l) p.OIDList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OIDList[i] a := &p.OIDList[i]
if len(data) < 8 {
goto overflow
}
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
} }
} }
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.CheckedList = make([]Oid, l) p.CheckedList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CheckedList[i] a := &p.CheckedList[i]
if len(data) < 8 {
goto overflow
}
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -1248,7 +1476,13 @@ func (p *AnswerFinishTransaction) NEOEncode(data []byte) { ...@@ -1248,7 +1476,13 @@ func (p *AnswerFinishTransaction) NEOEncode(data []byte) {
func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) { func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[8:])) p.Tid = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return int(nread) + 16, nil
...@@ -1271,7 +1505,13 @@ func (p *NotifyTransactionFinished) NEOEncode(data []byte) { ...@@ -1271,7 +1505,13 @@ func (p *NotifyTransactionFinished) NEOEncode(data []byte) {
func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) { func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return int(nread) + 16, nil
...@@ -1294,7 +1534,13 @@ func (p *LockInformation) NEOEncode(data []byte) { ...@@ -1294,7 +1534,13 @@ func (p *LockInformation) NEOEncode(data []byte) {
func (p *LockInformation) NEODecode(data []byte) (int, error) { func (p *LockInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Ttid = Tid(binary.BigEndian.Uint64(data[0:])) p.Ttid = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[8:])) p.Tid = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return int(nread) + 16, nil
...@@ -1316,6 +1562,9 @@ func (p *AnswerLockInformation) NEOEncode(data []byte) { ...@@ -1316,6 +1562,9 @@ func (p *AnswerLockInformation) NEOEncode(data []byte) {
func (p *AnswerLockInformation) NEODecode(data []byte) (int, error) { func (p *AnswerLockInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Ttid = Tid(binary.BigEndian.Uint64(data[0:])) p.Ttid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -1352,14 +1601,23 @@ func (p *InvalidateObjects) NEOEncode(data []byte) { ...@@ -1352,14 +1601,23 @@ func (p *InvalidateObjects) NEOEncode(data []byte) {
func (p *InvalidateObjects) NEODecode(data []byte) (int, error) { func (p *InvalidateObjects) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread += 12
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
if len(data) < 8 {
goto overflow
}
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -1385,6 +1643,9 @@ func (p *UnlockInformation) NEOEncode(data []byte) { ...@@ -1385,6 +1643,9 @@ func (p *UnlockInformation) NEOEncode(data []byte) {
func (p *UnlockInformation) NEODecode(data []byte) (int, error) { func (p *UnlockInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -1406,6 +1667,9 @@ func (p *GenerateOIDs) NEOEncode(data []byte) { ...@@ -1406,6 +1667,9 @@ func (p *GenerateOIDs) NEOEncode(data []byte) {
func (p *GenerateOIDs) NEODecode(data []byte) (int, error) { func (p *GenerateOIDs) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.NumOIDs = binary.BigEndian.Uint32(data[0:]) p.NumOIDs = binary.BigEndian.Uint32(data[0:])
return int(nread) + 4, nil return int(nread) + 4, nil
...@@ -1442,12 +1706,18 @@ func (p *AnswerGenerateOIDs) NEOEncode(data []byte) { ...@@ -1442,12 +1706,18 @@ func (p *AnswerGenerateOIDs) NEOEncode(data []byte) {
func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) { func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
if len(data) < 8 {
goto overflow
}
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -1513,43 +1783,127 @@ func (p *StoreObject) NEOEncode(data []byte) { ...@@ -1513,43 +1783,127 @@ func (p *StoreObject) NEOEncode(data []byte) {
func (p *StoreObject) NEODecode(data []byte) (int, error) { func (p *StoreObject) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[0:])) p.Oid = Oid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.Serial = Tid(binary.BigEndian.Uint64(data[8:])) p.Serial = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 17 {
goto overflow
}
p.Compression = byte2bool((data[16:])[0]) p.Compression = byte2bool((data[16:])[0])
if len(data) < 18 {
goto overflow
}
p.Checksum[0] = (data[17:])[0] p.Checksum[0] = (data[17:])[0]
if len(data) < 19 {
goto overflow
}
p.Checksum[1] = (data[18:])[0] p.Checksum[1] = (data[18:])[0]
if len(data) < 20 {
goto overflow
}
p.Checksum[2] = (data[19:])[0] p.Checksum[2] = (data[19:])[0]
if len(data) < 21 {
goto overflow
}
p.Checksum[3] = (data[20:])[0] p.Checksum[3] = (data[20:])[0]
if len(data) < 22 {
goto overflow
}
p.Checksum[4] = (data[21:])[0] p.Checksum[4] = (data[21:])[0]
if len(data) < 23 {
goto overflow
}
p.Checksum[5] = (data[22:])[0] p.Checksum[5] = (data[22:])[0]
if len(data) < 24 {
goto overflow
}
p.Checksum[6] = (data[23:])[0] p.Checksum[6] = (data[23:])[0]
if len(data) < 25 {
goto overflow
}
p.Checksum[7] = (data[24:])[0] p.Checksum[7] = (data[24:])[0]
if len(data) < 26 {
goto overflow
}
p.Checksum[8] = (data[25:])[0] p.Checksum[8] = (data[25:])[0]
if len(data) < 27 {
goto overflow
}
p.Checksum[9] = (data[26:])[0] p.Checksum[9] = (data[26:])[0]
if len(data) < 28 {
goto overflow
}
p.Checksum[10] = (data[27:])[0] p.Checksum[10] = (data[27:])[0]
if len(data) < 29 {
goto overflow
}
p.Checksum[11] = (data[28:])[0] p.Checksum[11] = (data[28:])[0]
if len(data) < 30 {
goto overflow
}
p.Checksum[12] = (data[29:])[0] p.Checksum[12] = (data[29:])[0]
if len(data) < 31 {
goto overflow
}
p.Checksum[13] = (data[30:])[0] p.Checksum[13] = (data[30:])[0]
if len(data) < 32 {
goto overflow
}
p.Checksum[14] = (data[31:])[0] p.Checksum[14] = (data[31:])[0]
if len(data) < 33 {
goto overflow
}
p.Checksum[15] = (data[32:])[0] p.Checksum[15] = (data[32:])[0]
if len(data) < 34 {
goto overflow
}
p.Checksum[16] = (data[33:])[0] p.Checksum[16] = (data[33:])[0]
if len(data) < 35 {
goto overflow
}
p.Checksum[17] = (data[34:])[0] p.Checksum[17] = (data[34:])[0]
if len(data) < 36 {
goto overflow
}
p.Checksum[18] = (data[35:])[0] p.Checksum[18] = (data[35:])[0]
if len(data) < 37 {
goto overflow
}
p.Checksum[19] = (data[36:])[0] p.Checksum[19] = (data[36:])[0]
{ {
if len(data) < 41 {
goto overflow
}
l := binary.BigEndian.Uint32(data[37:]) l := binary.BigEndian.Uint32(data[37:])
data = data[41:] data = data[41:]
nread += 41 nread += 41
p.Data = make([]byte, l) p.Data = make([]byte, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.Data[i] a := &p.Data[i]
if len(data) < 1 {
goto overflow
}
(*a) = (data[0:])[0] (*a) = (data[0:])[0]
data = data[1:] data = data[1:]
nread += 1 nread += 1
} }
} }
if len(data) < 8 {
goto overflow
}
p.DataSerial = Tid(binary.BigEndian.Uint64(data[0:])) p.DataSerial = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[8:])) p.Tid = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 17 {
goto overflow
}
p.Unlock = byte2bool((data[16:])[0]) p.Unlock = byte2bool((data[16:])[0])
return int(nread) + 17, nil return int(nread) + 17, nil
...@@ -1573,8 +1927,17 @@ func (p *AnswerStoreObject) NEOEncode(data []byte) { ...@@ -1573,8 +1927,17 @@ func (p *AnswerStoreObject) NEOEncode(data []byte) {
func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) { func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 1 {
goto overflow
}
p.Conflicting = byte2bool((data[0:])[0]) p.Conflicting = byte2bool((data[0:])[0])
if len(data) < 9 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[1:])) p.Oid = Oid(binary.BigEndian.Uint64(data[1:]))
if len(data) < 17 {
goto overflow
}
p.Serial = Tid(binary.BigEndian.Uint64(data[9:])) p.Serial = Tid(binary.BigEndian.Uint64(data[9:]))
return int(nread) + 17, nil return int(nread) + 17, nil
...@@ -1596,6 +1959,9 @@ func (p *AbortTransaction) NEOEncode(data []byte) { ...@@ -1596,6 +1959,9 @@ func (p *AbortTransaction) NEOEncode(data []byte) {
func (p *AbortTransaction) NEODecode(data []byte) (int, error) { func (p *AbortTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -1665,8 +2031,14 @@ func (p *StoreTransaction) NEOEncode(data []byte) { ...@@ -1665,8 +2031,14 @@ func (p *StoreTransaction) NEOEncode(data []byte) {
func (p *StoreTransaction) NEODecode(data []byte) (int, error) { func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -1677,6 +2049,9 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -1677,6 +2049,9 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
nread += 12 + l nread += 12 + l
} }
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -1687,6 +2062,9 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -1687,6 +2062,9 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
nread += 4 + l nread += 4 + l
} }
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -1697,12 +2075,18 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -1697,12 +2075,18 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
nread += 4 + l nread += 4 + l
} }
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
if len(data) < 8 {
goto overflow
}
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -1728,6 +2112,9 @@ func (p *VoteTransaction) NEOEncode(data []byte) { ...@@ -1728,6 +2112,9 @@ func (p *VoteTransaction) NEOEncode(data []byte) {
func (p *VoteTransaction) NEODecode(data []byte) (int, error) { func (p *VoteTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -1751,8 +2138,17 @@ func (p *GetObject) NEOEncode(data []byte) { ...@@ -1751,8 +2138,17 @@ func (p *GetObject) NEOEncode(data []byte) {
func (p *GetObject) NEODecode(data []byte) (int, error) { func (p *GetObject) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[0:])) p.Oid = Oid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.Serial = Tid(binary.BigEndian.Uint64(data[8:])) p.Serial = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 24 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[16:])) p.Tid = Tid(binary.BigEndian.Uint64(data[16:]))
return int(nread) + 24, nil return int(nread) + 24, nil
...@@ -1813,42 +2209,123 @@ func (p *AnswerGetObject) NEOEncode(data []byte) { ...@@ -1813,42 +2209,123 @@ func (p *AnswerGetObject) NEOEncode(data []byte) {
func (p *AnswerGetObject) NEODecode(data []byte) (int, error) { func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[0:])) p.Oid = Oid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.SerialStart = Tid(binary.BigEndian.Uint64(data[8:])) p.SerialStart = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 24 {
goto overflow
}
p.SerialEnd = Tid(binary.BigEndian.Uint64(data[16:])) p.SerialEnd = Tid(binary.BigEndian.Uint64(data[16:]))
if len(data) < 25 {
goto overflow
}
p.Compression = byte2bool((data[24:])[0]) p.Compression = byte2bool((data[24:])[0])
if len(data) < 26 {
goto overflow
}
p.Checksum[0] = (data[25:])[0] p.Checksum[0] = (data[25:])[0]
if len(data) < 27 {
goto overflow
}
p.Checksum[1] = (data[26:])[0] p.Checksum[1] = (data[26:])[0]
if len(data) < 28 {
goto overflow
}
p.Checksum[2] = (data[27:])[0] p.Checksum[2] = (data[27:])[0]
if len(data) < 29 {
goto overflow
}
p.Checksum[3] = (data[28:])[0] p.Checksum[3] = (data[28:])[0]
if len(data) < 30 {
goto overflow
}
p.Checksum[4] = (data[29:])[0] p.Checksum[4] = (data[29:])[0]
if len(data) < 31 {
goto overflow
}
p.Checksum[5] = (data[30:])[0] p.Checksum[5] = (data[30:])[0]
if len(data) < 32 {
goto overflow
}
p.Checksum[6] = (data[31:])[0] p.Checksum[6] = (data[31:])[0]
if len(data) < 33 {
goto overflow
}
p.Checksum[7] = (data[32:])[0] p.Checksum[7] = (data[32:])[0]
if len(data) < 34 {
goto overflow
}
p.Checksum[8] = (data[33:])[0] p.Checksum[8] = (data[33:])[0]
if len(data) < 35 {
goto overflow
}
p.Checksum[9] = (data[34:])[0] p.Checksum[9] = (data[34:])[0]
if len(data) < 36 {
goto overflow
}
p.Checksum[10] = (data[35:])[0] p.Checksum[10] = (data[35:])[0]
if len(data) < 37 {
goto overflow
}
p.Checksum[11] = (data[36:])[0] p.Checksum[11] = (data[36:])[0]
if len(data) < 38 {
goto overflow
}
p.Checksum[12] = (data[37:])[0] p.Checksum[12] = (data[37:])[0]
if len(data) < 39 {
goto overflow
}
p.Checksum[13] = (data[38:])[0] p.Checksum[13] = (data[38:])[0]
if len(data) < 40 {
goto overflow
}
p.Checksum[14] = (data[39:])[0] p.Checksum[14] = (data[39:])[0]
if len(data) < 41 {
goto overflow
}
p.Checksum[15] = (data[40:])[0] p.Checksum[15] = (data[40:])[0]
if len(data) < 42 {
goto overflow
}
p.Checksum[16] = (data[41:])[0] p.Checksum[16] = (data[41:])[0]
if len(data) < 43 {
goto overflow
}
p.Checksum[17] = (data[42:])[0] p.Checksum[17] = (data[42:])[0]
if len(data) < 44 {
goto overflow
}
p.Checksum[18] = (data[43:])[0] p.Checksum[18] = (data[43:])[0]
if len(data) < 45 {
goto overflow
}
p.Checksum[19] = (data[44:])[0] p.Checksum[19] = (data[44:])[0]
{ {
if len(data) < 49 {
goto overflow
}
l := binary.BigEndian.Uint32(data[45:]) l := binary.BigEndian.Uint32(data[45:])
data = data[49:] data = data[49:]
nread += 49 nread += 49
p.Data = make([]byte, l) p.Data = make([]byte, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.Data[i] a := &p.Data[i]
if len(data) < 1 {
goto overflow
}
(*a) = (data[0:])[0] (*a) = (data[0:])[0]
data = data[1:] data = data[1:]
nread += 1 nread += 1
} }
} }
if len(data) < 8 {
goto overflow
}
p.DataSerial = Tid(binary.BigEndian.Uint64(data[0:])) p.DataSerial = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -1872,8 +2349,17 @@ func (p *TIDList) NEOEncode(data []byte) { ...@@ -1872,8 +2349,17 @@ func (p *TIDList) NEOEncode(data []byte) {
func (p *TIDList) NEODecode(data []byte) (int, error) { func (p *TIDList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.First = binary.BigEndian.Uint64(data[0:]) p.First = binary.BigEndian.Uint64(data[0:])
if len(data) < 16 {
goto overflow
}
p.Last = binary.BigEndian.Uint64(data[8:]) p.Last = binary.BigEndian.Uint64(data[8:])
if len(data) < 20 {
goto overflow
}
p.Partition = binary.BigEndian.Uint32(data[16:]) p.Partition = binary.BigEndian.Uint32(data[16:])
return int(nread) + 20, nil return int(nread) + 20, nil
...@@ -1910,12 +2396,18 @@ func (p *AnswerTIDList) NEOEncode(data []byte) { ...@@ -1910,12 +2396,18 @@ func (p *AnswerTIDList) NEOEncode(data []byte) {
func (p *AnswerTIDList) NEODecode(data []byte) (int, error) { func (p *AnswerTIDList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.TIDList = make([]Tid, l) p.TIDList = make([]Tid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.TIDList[i] a := &p.TIDList[i]
if len(data) < 8 {
goto overflow
}
(*a) = Tid(binary.BigEndian.Uint64(data[0:])) (*a) = Tid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -1944,9 +2436,21 @@ func (p *TIDListFrom) NEOEncode(data []byte) { ...@@ -1944,9 +2436,21 @@ func (p *TIDListFrom) NEOEncode(data []byte) {
func (p *TIDListFrom) NEODecode(data []byte) (int, error) { func (p *TIDListFrom) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.MinTID = Tid(binary.BigEndian.Uint64(data[0:])) p.MinTID = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 20 {
goto overflow
}
p.Length = binary.BigEndian.Uint32(data[16:]) p.Length = binary.BigEndian.Uint32(data[16:])
if len(data) < 24 {
goto overflow
}
p.Partition = binary.BigEndian.Uint32(data[20:]) p.Partition = binary.BigEndian.Uint32(data[20:])
return int(nread) + 24, nil return int(nread) + 24, nil
...@@ -1983,12 +2487,18 @@ func (p *AnswerTIDListFrom) NEOEncode(data []byte) { ...@@ -1983,12 +2487,18 @@ func (p *AnswerTIDListFrom) NEOEncode(data []byte) {
func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) { func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.TidList = make([]Tid, l) p.TidList = make([]Tid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.TidList[i] a := &p.TidList[i]
if len(data) < 8 {
goto overflow
}
(*a) = Tid(binary.BigEndian.Uint64(data[0:])) (*a) = Tid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -2014,6 +2524,9 @@ func (p *TransactionInformation) NEOEncode(data []byte) { ...@@ -2014,6 +2524,9 @@ func (p *TransactionInformation) NEOEncode(data []byte) {
func (p *TransactionInformation) NEODecode(data []byte) (int, error) { func (p *TransactionInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -2084,8 +2597,14 @@ func (p *AnswerTransactionInformation) NEOEncode(data []byte) { ...@@ -2084,8 +2597,14 @@ func (p *AnswerTransactionInformation) NEOEncode(data []byte) {
func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -2096,6 +2615,9 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -2096,6 +2615,9 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
nread += 12 + l nread += 12 + l
} }
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -2106,6 +2628,9 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -2106,6 +2628,9 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
nread += 4 + l nread += 4 + l
} }
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -2115,14 +2640,23 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -2115,14 +2640,23 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 4 + l nread += 4 + l
} }
if len(data) < 1 {
goto overflow
}
p.Packed = byte2bool((data[0:])[0]) p.Packed = byte2bool((data[0:])[0])
{ {
if len(data) < 5 {
goto overflow
}
l := binary.BigEndian.Uint32(data[1:]) l := binary.BigEndian.Uint32(data[1:])
data = data[5:] data = data[5:]
nread += 5 nread += 5
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
if len(data) < 8 {
goto overflow
}
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -2150,8 +2684,17 @@ func (p *ObjectHistory) NEOEncode(data []byte) { ...@@ -2150,8 +2684,17 @@ func (p *ObjectHistory) NEOEncode(data []byte) {
func (p *ObjectHistory) NEODecode(data []byte) (int, error) { func (p *ObjectHistory) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[0:])) p.Oid = Oid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.First = binary.BigEndian.Uint64(data[8:]) p.First = binary.BigEndian.Uint64(data[8:])
if len(data) < 24 {
goto overflow
}
p.Last = binary.BigEndian.Uint64(data[16:]) p.Last = binary.BigEndian.Uint64(data[16:])
return int(nread) + 24, nil return int(nread) + 24, nil
...@@ -2189,8 +2732,14 @@ func (p *AnswerObjectHistory) NEOEncode(data []byte) { ...@@ -2189,8 +2732,14 @@ func (p *AnswerObjectHistory) NEOEncode(data []byte) {
func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) { func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[0:])) p.Oid = Oid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread += 12
...@@ -2200,7 +2749,13 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) { ...@@ -2200,7 +2749,13 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
}, l) }, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.HistoryList[i] a := &p.HistoryList[i]
if len(data) < 8 {
goto overflow
}
(*a).Serial = Tid(binary.BigEndian.Uint64(data[0:])) (*a).Serial = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 12 {
goto overflow
}
(*a).Size = binary.BigEndian.Uint32(data[8:]) (*a).Size = binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread += 12
...@@ -2228,8 +2783,17 @@ func (p *PartitionList) NEOEncode(data []byte) { ...@@ -2228,8 +2783,17 @@ func (p *PartitionList) NEOEncode(data []byte) {
func (p *PartitionList) NEODecode(data []byte) (int, error) { func (p *PartitionList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.MinOffset = binary.BigEndian.Uint32(data[0:]) p.MinOffset = binary.BigEndian.Uint32(data[0:])
if len(data) < 8 {
goto overflow
}
p.MaxOffset = binary.BigEndian.Uint32(data[4:]) p.MaxOffset = binary.BigEndian.Uint32(data[4:])
if len(data) < 12 {
goto overflow
}
p.UUID = UUID(int32(binary.BigEndian.Uint32(data[8:]))) p.UUID = UUID(int32(binary.BigEndian.Uint32(data[8:])))
return int(nread) + 12, nil return int(nread) + 12, nil
...@@ -2286,23 +2850,41 @@ func (p *AnswerPartitionList) NEOEncode(data []byte) { ...@@ -2286,23 +2850,41 @@ func (p *AnswerPartitionList) NEOEncode(data []byte) {
func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) { func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.PTid = PTid(binary.BigEndian.Uint64(data[0:])) p.PTid = PTid(binary.BigEndian.Uint64(data[0:]))
{ {
if len(data) < 12 {
goto overflow
}
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread += 12
p.RowList = make([]RowInfo, l) p.RowList = make([]RowInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
if len(data) < 4 {
goto overflow
}
(*a).Offset = binary.BigEndian.Uint32(data[0:]) (*a).Offset = binary.BigEndian.Uint32(data[0:])
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread += 8
(*a).CellList = make([]CellInfo, l) (*a).CellList = make([]CellInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
if len(data) < 4 {
goto overflow
}
(*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
if len(data) < 8 {
goto overflow
}
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -2332,6 +2914,9 @@ func (p *X_NodeList) NEOEncode(data []byte) { ...@@ -2332,6 +2914,9 @@ func (p *X_NodeList) NEOEncode(data []byte) {
func (p *X_NodeList) NEODecode(data []byte) (int, error) { func (p *X_NodeList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:]))) p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return int(nread) + 4, nil
...@@ -2387,14 +2972,23 @@ func (p *AnswerNodeList) NEOEncode(data []byte) { ...@@ -2387,14 +2972,23 @@ func (p *AnswerNodeList) NEOEncode(data []byte) {
func (p *AnswerNodeList) NEODecode(data []byte) (int, error) { func (p *AnswerNodeList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.NodeList = make([]NodeInfo, l) p.NodeList = make([]NodeInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
if len(data) < 4 {
goto overflow
}
(*a).NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:]))) (*a).NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:])))
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -2404,9 +2998,21 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) { ...@@ -2404,9 +2998,21 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 8 + l nread += 8 + l
} }
if len(data) < 2 {
goto overflow
}
(*a).Address.Port = binary.BigEndian.Uint16(data[0:]) (*a).Address.Port = binary.BigEndian.Uint16(data[0:])
if len(data) < 6 {
goto overflow
}
(*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[2:]))) (*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[2:])))
if len(data) < 10 {
goto overflow
}
(*a).NodeState = NodeState(int32(binary.BigEndian.Uint32(data[6:]))) (*a).NodeState = NodeState(int32(binary.BigEndian.Uint32(data[6:])))
if len(data) < 18 {
goto overflow
}
(*a).IdTimestamp = float64_NEODecode(data[10:]) (*a).IdTimestamp = float64_NEODecode(data[10:])
data = data[18:] data = data[18:]
nread += 18 nread += 18
...@@ -2433,7 +3039,13 @@ func (p *SetNodeState) NEOEncode(data []byte) { ...@@ -2433,7 +3039,13 @@ func (p *SetNodeState) NEOEncode(data []byte) {
func (p *SetNodeState) NEODecode(data []byte) (int, error) { func (p *SetNodeState) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.UUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) p.UUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
if len(data) < 8 {
goto overflow
}
p.NodeState = NodeState(int32(binary.BigEndian.Uint32(data[4:]))) p.NodeState = NodeState(int32(binary.BigEndian.Uint32(data[4:])))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -2470,12 +3082,18 @@ func (p *AddPendingNodes) NEOEncode(data []byte) { ...@@ -2470,12 +3082,18 @@ func (p *AddPendingNodes) NEOEncode(data []byte) {
func (p *AddPendingNodes) NEODecode(data []byte) (int, error) { func (p *AddPendingNodes) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.UUIDList = make([]UUID, l) p.UUIDList = make([]UUID, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.UUIDList[i] a := &p.UUIDList[i]
if len(data) < 4 {
goto overflow
}
(*a) = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a) = UUID(int32(binary.BigEndian.Uint32(data[0:])))
data = data[4:] data = data[4:]
nread += 4 nread += 4
...@@ -2516,12 +3134,18 @@ func (p *TweakPartitionTable) NEOEncode(data []byte) { ...@@ -2516,12 +3134,18 @@ func (p *TweakPartitionTable) NEOEncode(data []byte) {
func (p *TweakPartitionTable) NEODecode(data []byte) (int, error) { func (p *TweakPartitionTable) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.UUIDList = make([]UUID, l) p.UUIDList = make([]UUID, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.UUIDList[i] a := &p.UUIDList[i]
if len(data) < 4 {
goto overflow
}
(*a) = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a) = UUID(int32(binary.BigEndian.Uint32(data[0:])))
data = data[4:] data = data[4:]
nread += 4 nread += 4
...@@ -2581,14 +3205,23 @@ func (p *NotifyNodeInformation) NEOEncode(data []byte) { ...@@ -2581,14 +3205,23 @@ func (p *NotifyNodeInformation) NEOEncode(data []byte) {
func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) { func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.NodeList = make([]NodeInfo, l) p.NodeList = make([]NodeInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
if len(data) < 4 {
goto overflow
}
(*a).NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:]))) (*a).NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:])))
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -2598,9 +3231,21 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) { ...@@ -2598,9 +3231,21 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 8 + l nread += 8 + l
} }
if len(data) < 2 {
goto overflow
}
(*a).Address.Port = binary.BigEndian.Uint16(data[0:]) (*a).Address.Port = binary.BigEndian.Uint16(data[0:])
if len(data) < 6 {
goto overflow
}
(*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[2:]))) (*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[2:])))
if len(data) < 10 {
goto overflow
}
(*a).NodeState = NodeState(int32(binary.BigEndian.Uint32(data[6:]))) (*a).NodeState = NodeState(int32(binary.BigEndian.Uint32(data[6:])))
if len(data) < 18 {
goto overflow
}
(*a).IdTimestamp = float64_NEODecode(data[10:]) (*a).IdTimestamp = float64_NEODecode(data[10:])
data = data[18:] data = data[18:]
nread += 18 nread += 18
...@@ -2645,6 +3290,9 @@ func (p *SetClusterState) NEOEncode(data []byte) { ...@@ -2645,6 +3290,9 @@ func (p *SetClusterState) NEOEncode(data []byte) {
func (p *SetClusterState) NEODecode(data []byte) (int, error) { func (p *SetClusterState) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:]))) p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return int(nread) + 4, nil
...@@ -2666,6 +3314,9 @@ func (p *ClusterInformation) NEOEncode(data []byte) { ...@@ -2666,6 +3314,9 @@ func (p *ClusterInformation) NEOEncode(data []byte) {
func (p *ClusterInformation) NEODecode(data []byte) (int, error) { func (p *ClusterInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:]))) p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return int(nread) + 4, nil
...@@ -2687,6 +3338,9 @@ func (p *X_ClusterState) NEOEncode(data []byte) { ...@@ -2687,6 +3338,9 @@ func (p *X_ClusterState) NEOEncode(data []byte) {
func (p *X_ClusterState) NEODecode(data []byte) (int, error) { func (p *X_ClusterState) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:]))) p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return int(nread) + 4, nil
...@@ -2725,16 +3379,31 @@ func (p *ObjectUndoSerial) NEOEncode(data []byte) { ...@@ -2725,16 +3379,31 @@ func (p *ObjectUndoSerial) NEOEncode(data []byte) {
func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) { func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.LTID = Tid(binary.BigEndian.Uint64(data[8:])) p.LTID = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 24 {
goto overflow
}
p.UndoneTID = Tid(binary.BigEndian.Uint64(data[16:])) p.UndoneTID = Tid(binary.BigEndian.Uint64(data[16:]))
{ {
if len(data) < 28 {
goto overflow
}
l := binary.BigEndian.Uint32(data[24:]) l := binary.BigEndian.Uint32(data[24:])
data = data[28:] data = data[28:]
nread += 28 nread += 28
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
if len(data) < 8 {
goto overflow
}
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread += 8
...@@ -2783,6 +3452,9 @@ func (p *AnswerObjectUndoSerial) NEOEncode(data []byte) { ...@@ -2783,6 +3452,9 @@ func (p *AnswerObjectUndoSerial) NEOEncode(data []byte) {
func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) { func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
...@@ -2793,14 +3465,26 @@ func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) { ...@@ -2793,14 +3465,26 @@ func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) {
}, l) }, l)
m := p.ObjectTIDDict m := p.ObjectTIDDict
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
if len(data) < 8 {
goto overflow
}
key := Oid(binary.BigEndian.Uint64(data[0:])) key := Oid(binary.BigEndian.Uint64(data[0:]))
var v struct { var v struct {
CurrentSerial Tid CurrentSerial Tid
UndoSerial Tid UndoSerial Tid
IsCurrent bool IsCurrent bool
} }
if len(data) < 16 {
goto overflow
}
v.CurrentSerial = Tid(binary.BigEndian.Uint64(data[8:])) v.CurrentSerial = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 24 {
goto overflow
}
v.UndoSerial = Tid(binary.BigEndian.Uint64(data[16:])) v.UndoSerial = Tid(binary.BigEndian.Uint64(data[16:]))
if len(data) < 25 {
goto overflow
}
v.IsCurrent = byte2bool((data[24:])[0]) v.IsCurrent = byte2bool((data[24:])[0])
m[key] = v m[key] = v
data = data[25:] data = data[25:]
...@@ -2828,7 +3512,13 @@ func (p *HasLock) NEOEncode(data []byte) { ...@@ -2828,7 +3512,13 @@ func (p *HasLock) NEOEncode(data []byte) {
func (p *HasLock) NEODecode(data []byte) (int, error) { func (p *HasLock) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[8:])) p.Oid = Oid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return int(nread) + 16, nil
...@@ -2851,7 +3541,13 @@ func (p *AnswerHasLock) NEOEncode(data []byte) { ...@@ -2851,7 +3541,13 @@ func (p *AnswerHasLock) NEOEncode(data []byte) {
func (p *AnswerHasLock) NEODecode(data []byte) (int, error) { func (p *AnswerHasLock) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[0:])) p.Oid = Oid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 12 {
goto overflow
}
p.LockState = LockState(int32(binary.BigEndian.Uint32(data[8:]))) p.LockState = LockState(int32(binary.BigEndian.Uint32(data[8:])))
return int(nread) + 12, nil return int(nread) + 12, nil
...@@ -2875,8 +3571,17 @@ func (p *CheckCurrentSerial) NEOEncode(data []byte) { ...@@ -2875,8 +3571,17 @@ func (p *CheckCurrentSerial) NEOEncode(data []byte) {
func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) { func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.Serial = Tid(binary.BigEndian.Uint64(data[8:])) p.Serial = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 24 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[16:])) p.Oid = Oid(binary.BigEndian.Uint64(data[16:]))
return int(nread) + 24, nil return int(nread) + 24, nil
...@@ -2900,8 +3605,17 @@ func (p *AnswerCheckCurrentSerial) NEOEncode(data []byte) { ...@@ -2900,8 +3605,17 @@ func (p *AnswerCheckCurrentSerial) NEOEncode(data []byte) {
func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) { func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 1 {
goto overflow
}
p.Conflicting = byte2bool((data[0:])[0]) p.Conflicting = byte2bool((data[0:])[0])
if len(data) < 9 {
goto overflow
}
p.Oid = Oid(binary.BigEndian.Uint64(data[1:])) p.Oid = Oid(binary.BigEndian.Uint64(data[1:]))
if len(data) < 17 {
goto overflow
}
p.Serial = Tid(binary.BigEndian.Uint64(data[9:])) p.Serial = Tid(binary.BigEndian.Uint64(data[9:]))
return int(nread) + 17, nil return int(nread) + 17, nil
...@@ -2923,6 +3637,9 @@ func (p *Pack) NEOEncode(data []byte) { ...@@ -2923,6 +3637,9 @@ func (p *Pack) NEOEncode(data []byte) {
func (p *Pack) NEODecode(data []byte) (int, error) { func (p *Pack) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
...@@ -2944,6 +3661,9 @@ func (p *AnswerPack) NEOEncode(data []byte) { ...@@ -2944,6 +3661,9 @@ func (p *AnswerPack) NEOEncode(data []byte) {
func (p *AnswerPack) NEODecode(data []byte) (int, error) { func (p *AnswerPack) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 1 {
goto overflow
}
p.Status = byte2bool((data[0:])[0]) p.Status = byte2bool((data[0:])[0])
return int(nread) + 1, nil return int(nread) + 1, nil
...@@ -2988,19 +3708,34 @@ func (p *CheckReplicas) NEOEncode(data []byte) { ...@@ -2988,19 +3708,34 @@ func (p *CheckReplicas) NEOEncode(data []byte) {
func (p *CheckReplicas) NEODecode(data []byte) (int, error) { func (p *CheckReplicas) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread += 4
p.PartitionDict = make(map[uint32]UUID, l) p.PartitionDict = make(map[uint32]UUID, l)
m := p.PartitionDict m := p.PartitionDict
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
if len(data) < 4 {
goto overflow
}
key := binary.BigEndian.Uint32(data[0:]) key := binary.BigEndian.Uint32(data[0:])
if len(data) < 8 {
goto overflow
}
m[key] = UUID(int32(binary.BigEndian.Uint32(data[4:]))) m[key] = UUID(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread += 8
} }
} }
if len(data) < 8 {
goto overflow
}
p.MinTID = Tid(binary.BigEndian.Uint64(data[0:])) p.MinTID = Tid(binary.BigEndian.Uint64(data[0:]))
if len(data) < 16 {
goto overflow
}
p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return int(nread) + 16, nil
...@@ -3047,8 +3782,14 @@ func (p *CheckPartition) NEOEncode(data []byte) { ...@@ -3047,8 +3782,14 @@ func (p *CheckPartition) NEOEncode(data []byte) {
func (p *CheckPartition) NEODecode(data []byte) (int, error) { func (p *CheckPartition) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.Partition = binary.BigEndian.Uint32(data[0:]) p.Partition = binary.BigEndian.Uint32(data[0:])
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -3059,6 +3800,9 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) { ...@@ -3059,6 +3800,9 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
nread += 8 + l nread += 8 + l
} }
{ {
if len(data) < 4 {
goto overflow
}
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
if uint32(len(data)) < l { if uint32(len(data)) < l {
...@@ -3068,8 +3812,17 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) { ...@@ -3068,8 +3812,17 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
nread += 4 + l nread += 4 + l
} }
if len(data) < 2 {
goto overflow
}
p.Source.Address.Port = binary.BigEndian.Uint16(data[0:]) p.Source.Address.Port = binary.BigEndian.Uint16(data[0:])
if len(data) < 10 {
goto overflow
}
p.MinTID = Tid(binary.BigEndian.Uint64(data[2:])) p.MinTID = Tid(binary.BigEndian.Uint64(data[2:]))
if len(data) < 18 {
goto overflow
}
p.MaxTID = Tid(binary.BigEndian.Uint64(data[10:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[10:]))
return int(nread) + 18, nil return int(nread) + 18, nil
...@@ -3094,9 +3847,21 @@ func (p *CheckTIDRange) NEOEncode(data []byte) { ...@@ -3094,9 +3847,21 @@ func (p *CheckTIDRange) NEOEncode(data []byte) {
func (p *CheckTIDRange) NEODecode(data []byte) (int, error) { func (p *CheckTIDRange) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.Partition = binary.BigEndian.Uint32(data[0:]) p.Partition = binary.BigEndian.Uint32(data[0:])
if len(data) < 8 {
goto overflow
}
p.Length = binary.BigEndian.Uint32(data[4:]) p.Length = binary.BigEndian.Uint32(data[4:])
if len(data) < 16 {
goto overflow
}
p.MinTID = Tid(binary.BigEndian.Uint64(data[8:])) p.MinTID = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 24 {
goto overflow
}
p.MaxTID = Tid(binary.BigEndian.Uint64(data[16:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[16:]))
return int(nread) + 24, nil return int(nread) + 24, nil
...@@ -3139,27 +3904,93 @@ func (p *AnswerCheckTIDRange) NEOEncode(data []byte) { ...@@ -3139,27 +3904,93 @@ func (p *AnswerCheckTIDRange) NEOEncode(data []byte) {
func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) { func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.Count = binary.BigEndian.Uint32(data[0:]) p.Count = binary.BigEndian.Uint32(data[0:])
if len(data) < 5 {
goto overflow
}
p.Checksum[0] = (data[4:])[0] p.Checksum[0] = (data[4:])[0]
if len(data) < 6 {
goto overflow
}
p.Checksum[1] = (data[5:])[0] p.Checksum[1] = (data[5:])[0]
if len(data) < 7 {
goto overflow
}
p.Checksum[2] = (data[6:])[0] p.Checksum[2] = (data[6:])[0]
if len(data) < 8 {
goto overflow
}
p.Checksum[3] = (data[7:])[0] p.Checksum[3] = (data[7:])[0]
if len(data) < 9 {
goto overflow
}
p.Checksum[4] = (data[8:])[0] p.Checksum[4] = (data[8:])[0]
if len(data) < 10 {
goto overflow
}
p.Checksum[5] = (data[9:])[0] p.Checksum[5] = (data[9:])[0]
if len(data) < 11 {
goto overflow
}
p.Checksum[6] = (data[10:])[0] p.Checksum[6] = (data[10:])[0]
if len(data) < 12 {
goto overflow
}
p.Checksum[7] = (data[11:])[0] p.Checksum[7] = (data[11:])[0]
if len(data) < 13 {
goto overflow
}
p.Checksum[8] = (data[12:])[0] p.Checksum[8] = (data[12:])[0]
if len(data) < 14 {
goto overflow
}
p.Checksum[9] = (data[13:])[0] p.Checksum[9] = (data[13:])[0]
if len(data) < 15 {
goto overflow
}
p.Checksum[10] = (data[14:])[0] p.Checksum[10] = (data[14:])[0]
if len(data) < 16 {
goto overflow
}
p.Checksum[11] = (data[15:])[0] p.Checksum[11] = (data[15:])[0]
if len(data) < 17 {
goto overflow
}
p.Checksum[12] = (data[16:])[0] p.Checksum[12] = (data[16:])[0]
if len(data) < 18 {
goto overflow
}
p.Checksum[13] = (data[17:])[0] p.Checksum[13] = (data[17:])[0]
if len(data) < 19 {
goto overflow
}
p.Checksum[14] = (data[18:])[0] p.Checksum[14] = (data[18:])[0]
if len(data) < 20 {
goto overflow
}
p.Checksum[15] = (data[19:])[0] p.Checksum[15] = (data[19:])[0]
if len(data) < 21 {
goto overflow
}
p.Checksum[16] = (data[20:])[0] p.Checksum[16] = (data[20:])[0]
if len(data) < 22 {
goto overflow
}
p.Checksum[17] = (data[21:])[0] p.Checksum[17] = (data[21:])[0]
if len(data) < 23 {
goto overflow
}
p.Checksum[18] = (data[22:])[0] p.Checksum[18] = (data[22:])[0]
if len(data) < 24 {
goto overflow
}
p.Checksum[19] = (data[23:])[0] p.Checksum[19] = (data[23:])[0]
if len(data) < 32 {
goto overflow
}
p.MaxTID = Tid(binary.BigEndian.Uint64(data[24:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[24:]))
return int(nread) + 32, nil return int(nread) + 32, nil
...@@ -3185,10 +4016,25 @@ func (p *CheckSerialRange) NEOEncode(data []byte) { ...@@ -3185,10 +4016,25 @@ func (p *CheckSerialRange) NEOEncode(data []byte) {
func (p *CheckSerialRange) NEODecode(data []byte) (int, error) { func (p *CheckSerialRange) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.Partition = binary.BigEndian.Uint32(data[0:]) p.Partition = binary.BigEndian.Uint32(data[0:])
if len(data) < 8 {
goto overflow
}
p.Length = binary.BigEndian.Uint32(data[4:]) p.Length = binary.BigEndian.Uint32(data[4:])
if len(data) < 16 {
goto overflow
}
p.MinTID = Tid(binary.BigEndian.Uint64(data[8:])) p.MinTID = Tid(binary.BigEndian.Uint64(data[8:]))
if len(data) < 24 {
goto overflow
}
p.MaxTID = Tid(binary.BigEndian.Uint64(data[16:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[16:]))
if len(data) < 32 {
goto overflow
}
p.MinOID = Oid(binary.BigEndian.Uint64(data[24:])) p.MinOID = Oid(binary.BigEndian.Uint64(data[24:]))
return int(nread) + 32, nil return int(nread) + 32, nil
...@@ -3252,48 +4098,177 @@ func (p *AnswerCheckSerialRange) NEOEncode(data []byte) { ...@@ -3252,48 +4098,177 @@ func (p *AnswerCheckSerialRange) NEOEncode(data []byte) {
func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) { func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.Count = binary.BigEndian.Uint32(data[0:]) p.Count = binary.BigEndian.Uint32(data[0:])
if len(data) < 5 {
goto overflow
}
p.TidChecksum[0] = (data[4:])[0] p.TidChecksum[0] = (data[4:])[0]
if len(data) < 6 {
goto overflow
}
p.TidChecksum[1] = (data[5:])[0] p.TidChecksum[1] = (data[5:])[0]
if len(data) < 7 {
goto overflow
}
p.TidChecksum[2] = (data[6:])[0] p.TidChecksum[2] = (data[6:])[0]
if len(data) < 8 {
goto overflow
}
p.TidChecksum[3] = (data[7:])[0] p.TidChecksum[3] = (data[7:])[0]
if len(data) < 9 {
goto overflow
}
p.TidChecksum[4] = (data[8:])[0] p.TidChecksum[4] = (data[8:])[0]
if len(data) < 10 {
goto overflow
}
p.TidChecksum[5] = (data[9:])[0] p.TidChecksum[5] = (data[9:])[0]
if len(data) < 11 {
goto overflow
}
p.TidChecksum[6] = (data[10:])[0] p.TidChecksum[6] = (data[10:])[0]
if len(data) < 12 {
goto overflow
}
p.TidChecksum[7] = (data[11:])[0] p.TidChecksum[7] = (data[11:])[0]
if len(data) < 13 {
goto overflow
}
p.TidChecksum[8] = (data[12:])[0] p.TidChecksum[8] = (data[12:])[0]
if len(data) < 14 {
goto overflow
}
p.TidChecksum[9] = (data[13:])[0] p.TidChecksum[9] = (data[13:])[0]
if len(data) < 15 {
goto overflow
}
p.TidChecksum[10] = (data[14:])[0] p.TidChecksum[10] = (data[14:])[0]
if len(data) < 16 {
goto overflow
}
p.TidChecksum[11] = (data[15:])[0] p.TidChecksum[11] = (data[15:])[0]
if len(data) < 17 {
goto overflow
}
p.TidChecksum[12] = (data[16:])[0] p.TidChecksum[12] = (data[16:])[0]
if len(data) < 18 {
goto overflow
}
p.TidChecksum[13] = (data[17:])[0] p.TidChecksum[13] = (data[17:])[0]
if len(data) < 19 {
goto overflow
}
p.TidChecksum[14] = (data[18:])[0] p.TidChecksum[14] = (data[18:])[0]
if len(data) < 20 {
goto overflow
}
p.TidChecksum[15] = (data[19:])[0] p.TidChecksum[15] = (data[19:])[0]
if len(data) < 21 {
goto overflow
}
p.TidChecksum[16] = (data[20:])[0] p.TidChecksum[16] = (data[20:])[0]
if len(data) < 22 {
goto overflow
}
p.TidChecksum[17] = (data[21:])[0] p.TidChecksum[17] = (data[21:])[0]
if len(data) < 23 {
goto overflow
}
p.TidChecksum[18] = (data[22:])[0] p.TidChecksum[18] = (data[22:])[0]
if len(data) < 24 {
goto overflow
}
p.TidChecksum[19] = (data[23:])[0] p.TidChecksum[19] = (data[23:])[0]
if len(data) < 32 {
goto overflow
}
p.MaxTID = Tid(binary.BigEndian.Uint64(data[24:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[24:]))
if len(data) < 33 {
goto overflow
}
p.OidChecksum[0] = (data[32:])[0] p.OidChecksum[0] = (data[32:])[0]
if len(data) < 34 {
goto overflow
}
p.OidChecksum[1] = (data[33:])[0] p.OidChecksum[1] = (data[33:])[0]
if len(data) < 35 {
goto overflow
}
p.OidChecksum[2] = (data[34:])[0] p.OidChecksum[2] = (data[34:])[0]
if len(data) < 36 {
goto overflow
}
p.OidChecksum[3] = (data[35:])[0] p.OidChecksum[3] = (data[35:])[0]
if len(data) < 37 {
goto overflow
}
p.OidChecksum[4] = (data[36:])[0] p.OidChecksum[4] = (data[36:])[0]
if len(data) < 38 {
goto overflow
}
p.OidChecksum[5] = (data[37:])[0] p.OidChecksum[5] = (data[37:])[0]
if len(data) < 39 {
goto overflow
}
p.OidChecksum[6] = (data[38:])[0] p.OidChecksum[6] = (data[38:])[0]
if len(data) < 40 {
goto overflow
}
p.OidChecksum[7] = (data[39:])[0] p.OidChecksum[7] = (data[39:])[0]
if len(data) < 41 {
goto overflow
}
p.OidChecksum[8] = (data[40:])[0] p.OidChecksum[8] = (data[40:])[0]
if len(data) < 42 {
goto overflow
}
p.OidChecksum[9] = (data[41:])[0] p.OidChecksum[9] = (data[41:])[0]
if len(data) < 43 {
goto overflow
}
p.OidChecksum[10] = (data[42:])[0] p.OidChecksum[10] = (data[42:])[0]
if len(data) < 44 {
goto overflow
}
p.OidChecksum[11] = (data[43:])[0] p.OidChecksum[11] = (data[43:])[0]
if len(data) < 45 {
goto overflow
}
p.OidChecksum[12] = (data[44:])[0] p.OidChecksum[12] = (data[44:])[0]
if len(data) < 46 {
goto overflow
}
p.OidChecksum[13] = (data[45:])[0] p.OidChecksum[13] = (data[45:])[0]
if len(data) < 47 {
goto overflow
}
p.OidChecksum[14] = (data[46:])[0] p.OidChecksum[14] = (data[46:])[0]
if len(data) < 48 {
goto overflow
}
p.OidChecksum[15] = (data[47:])[0] p.OidChecksum[15] = (data[47:])[0]
if len(data) < 49 {
goto overflow
}
p.OidChecksum[16] = (data[48:])[0] p.OidChecksum[16] = (data[48:])[0]
if len(data) < 50 {
goto overflow
}
p.OidChecksum[17] = (data[49:])[0] p.OidChecksum[17] = (data[49:])[0]
if len(data) < 51 {
goto overflow
}
p.OidChecksum[18] = (data[50:])[0] p.OidChecksum[18] = (data[50:])[0]
if len(data) < 52 {
goto overflow
}
p.OidChecksum[19] = (data[51:])[0] p.OidChecksum[19] = (data[51:])[0]
if len(data) < 60 {
goto overflow
}
p.MaxOID = Oid(binary.BigEndian.Uint64(data[52:])) p.MaxOID = Oid(binary.BigEndian.Uint64(data[52:]))
return int(nread) + 60, nil return int(nread) + 60, nil
...@@ -3330,14 +4305,23 @@ func (p *PartitionCorrupted) NEOEncode(data []byte) { ...@@ -3330,14 +4305,23 @@ func (p *PartitionCorrupted) NEOEncode(data []byte) {
func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) { func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 4 {
goto overflow
}
p.Partition = binary.BigEndian.Uint32(data[0:]) p.Partition = binary.BigEndian.Uint32(data[0:])
{ {
if len(data) < 8 {
goto overflow
}
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread += 8
p.CellList = make([]UUID, l) p.CellList = make([]UUID, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
if len(data) < 4 {
goto overflow
}
(*a) = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a) = UUID(int32(binary.BigEndian.Uint32(data[0:])))
data = data[4:] data = data[4:]
nread += 4 nread += 4
...@@ -3382,6 +4366,9 @@ func (p *AnswerLastTransaction) NEOEncode(data []byte) { ...@@ -3382,6 +4366,9 @@ func (p *AnswerLastTransaction) NEOEncode(data []byte) {
func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) { func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
if len(data) < 8 {
goto overflow
}
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return int(nread) + 8, nil
......
...@@ -297,6 +297,7 @@ func (e *encoder) genBasic(path string, typ *types.Basic, userType types.Type, o ...@@ -297,6 +297,7 @@ func (e *encoder) genBasic(path string, typ *types.Basic, userType types.Type, o
func (d *decoder) genBasic(assignto string, typ *types.Basic, userType types.Type, obj types.Object) { func (d *decoder) genBasic(assignto string, typ *types.Basic, userType types.Type, obj types.Object) {
basic := basicTypes[typ.Kind()] basic := basicTypes[typ.Kind()]
d.emit("if len(data) < %v { goto overflow }", d.n + basic.wireSize)
dataptr := fmt.Sprintf("data[%v:]", d.n) dataptr := fmt.Sprintf("data[%v:]", d.n)
decoded := fmt.Sprintf(basic.decode, dataptr) decoded := fmt.Sprintf(basic.decode, dataptr)
d.n += basic.wireSize d.n += basic.wireSize
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment