Commit d5f0a174 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1b738098
...@@ -14,7 +14,7 @@ func (p *Address) NEODecode(data []byte) (int, error) { ...@@ -14,7 +14,7 @@ func (p *Address) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Host = string(data[:l]) p.Host = string(data[:l])
data = data[l:] data = data[l:]
...@@ -22,6 +22,9 @@ func (p *Address) NEODecode(data []byte) (int, error) { ...@@ -22,6 +22,9 @@ func (p *Address) NEODecode(data []byte) (int, error) {
} }
p.Port = binary.BigEndian.Uint16(data[0:]) p.Port = binary.BigEndian.Uint16(data[0:])
return int(nread) + 2, nil return int(nread) + 2, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 1. NodeInfo // 1. NodeInfo
...@@ -33,7 +36,7 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) { ...@@ -33,7 +36,7 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Address.Host = string(data[:l]) p.Address.Host = string(data[:l])
data = data[l:] data = data[l:]
...@@ -44,6 +47,9 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) { ...@@ -44,6 +47,9 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) {
p.NodeState = NodeState(int32(binary.BigEndian.Uint32(data[6:]))) p.NodeState = NodeState(int32(binary.BigEndian.Uint32(data[6:])))
p.IdTimestamp = float64_NEODecode(data[10:]) p.IdTimestamp = float64_NEODecode(data[10:])
return int(nread) + 18, nil return int(nread) + 18, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 2. CellInfo // 2. CellInfo
...@@ -53,6 +59,9 @@ func (p *CellInfo) NEODecode(data []byte) (int, error) { ...@@ -53,6 +59,9 @@ func (p *CellInfo) NEODecode(data []byte) (int, error) {
p.UUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) p.UUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 3. RowInfo // 3. RowInfo
...@@ -74,6 +83,9 @@ func (p *RowInfo) NEODecode(data []byte) (int, error) { ...@@ -74,6 +83,9 @@ func (p *RowInfo) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 4. Notify // 4. Notify
...@@ -84,13 +96,16 @@ func (p *Notify) NEODecode(data []byte) (int, error) { ...@@ -84,13 +96,16 @@ func (p *Notify) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Message = string(data[:l]) p.Message = string(data[:l])
data = data[l:] data = data[l:]
nread += 4 + l nread += 4 + l
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 5. Error // 5. Error
...@@ -102,13 +117,16 @@ func (p *Error) NEODecode(data []byte) (int, error) { ...@@ -102,13 +117,16 @@ func (p *Error) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Message = string(data[:l]) p.Message = string(data[:l])
data = data[l:] data = data[l:]
nread += 8 + l nread += 8 + l
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 6. Ping // 6. Ping
...@@ -116,6 +134,9 @@ func (p *Error) NEODecode(data []byte) (int, error) { ...@@ -116,6 +134,9 @@ func (p *Error) NEODecode(data []byte) (int, error) {
func (p *Ping) NEODecode(data []byte) (int, error) { func (p *Ping) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 7. CloseClient // 7. CloseClient
...@@ -123,6 +144,9 @@ func (p *Ping) NEODecode(data []byte) (int, error) { ...@@ -123,6 +144,9 @@ func (p *Ping) NEODecode(data []byte) (int, error) {
func (p *CloseClient) NEODecode(data []byte) (int, error) { func (p *CloseClient) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 8. RequestIdentification // 8. RequestIdentification
...@@ -136,7 +160,7 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) { ...@@ -136,7 +160,7 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Address.Host = string(data[:l]) p.Address.Host = string(data[:l])
data = data[l:] data = data[l:]
...@@ -147,7 +171,7 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) { ...@@ -147,7 +171,7 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Name = string(data[:l]) p.Name = string(data[:l])
data = data[l:] data = data[l:]
...@@ -155,6 +179,9 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) { ...@@ -155,6 +179,9 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) {
} }
p.IdTimestamp = float64_NEODecode(data[0:]) p.IdTimestamp = float64_NEODecode(data[0:])
return int(nread) + 8, nil return int(nread) + 8, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 9. AcceptIdentification // 9. AcceptIdentification
...@@ -170,7 +197,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -170,7 +197,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Primary.Host = string(data[:l]) p.Primary.Host = string(data[:l])
data = data[l:] data = data[l:]
...@@ -191,7 +218,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -191,7 +218,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
(*a).Address.Host = string(data[:l]) (*a).Address.Host = string(data[:l])
data = data[l:] data = data[l:]
...@@ -204,6 +231,9 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -204,6 +231,9 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 10. PrimaryMaster // 10. PrimaryMaster
...@@ -211,6 +241,9 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -211,6 +241,9 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
func (p *PrimaryMaster) NEODecode(data []byte) (int, error) { func (p *PrimaryMaster) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 11. AnswerPrimary // 11. AnswerPrimary
...@@ -219,6 +252,9 @@ func (p *AnswerPrimary) NEODecode(data []byte) (int, error) { ...@@ -219,6 +252,9 @@ func (p *AnswerPrimary) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 12. AnnouncePrimary // 12. AnnouncePrimary
...@@ -226,6 +262,9 @@ func (p *AnswerPrimary) NEODecode(data []byte) (int, error) { ...@@ -226,6 +262,9 @@ func (p *AnswerPrimary) NEODecode(data []byte) (int, error) {
func (p *AnnouncePrimary) NEODecode(data []byte) (int, error) { func (p *AnnouncePrimary) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 13. ReelectPrimary // 13. ReelectPrimary
...@@ -233,6 +272,9 @@ func (p *AnnouncePrimary) NEODecode(data []byte) (int, error) { ...@@ -233,6 +272,9 @@ func (p *AnnouncePrimary) NEODecode(data []byte) (int, error) {
func (p *ReelectPrimary) NEODecode(data []byte) (int, error) { func (p *ReelectPrimary) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 14. Recovery // 14. Recovery
...@@ -240,6 +282,9 @@ func (p *ReelectPrimary) NEODecode(data []byte) (int, error) { ...@@ -240,6 +282,9 @@ func (p *ReelectPrimary) NEODecode(data []byte) (int, error) {
func (p *Recovery) NEODecode(data []byte) (int, error) { func (p *Recovery) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 15. AnswerRecovery // 15. AnswerRecovery
...@@ -250,6 +295,9 @@ func (p *AnswerRecovery) NEODecode(data []byte) (int, error) { ...@@ -250,6 +295,9 @@ func (p *AnswerRecovery) NEODecode(data []byte) (int, error) {
p.BackupTID = Tid(binary.BigEndian.Uint64(data[8:])) p.BackupTID = Tid(binary.BigEndian.Uint64(data[8:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 16. LastIDs // 16. LastIDs
...@@ -257,6 +305,9 @@ func (p *AnswerRecovery) NEODecode(data []byte) (int, error) { ...@@ -257,6 +305,9 @@ func (p *AnswerRecovery) NEODecode(data []byte) (int, error) {
func (p *LastIDs) NEODecode(data []byte) (int, error) { func (p *LastIDs) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 17. AnswerLastIDs // 17. AnswerLastIDs
...@@ -266,6 +317,9 @@ func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) { ...@@ -266,6 +317,9 @@ func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) {
p.LastOID = Oid(binary.BigEndian.Uint64(data[0:])) p.LastOID = Oid(binary.BigEndian.Uint64(data[0:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 18. PartitionTable // 18. PartitionTable
...@@ -273,6 +327,9 @@ func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) { ...@@ -273,6 +327,9 @@ func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) {
func (p *PartitionTable) NEODecode(data []byte) (int, error) { func (p *PartitionTable) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 19. AnswerPartitionTable // 19. AnswerPartitionTable
...@@ -306,6 +363,9 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -306,6 +363,9 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 20. NotifyPartitionTable // 20. NotifyPartitionTable
...@@ -339,6 +399,9 @@ func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -339,6 +399,9 @@ func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 21. PartitionChanges // 21. PartitionChanges
...@@ -365,6 +428,9 @@ func (p *PartitionChanges) NEODecode(data []byte) (int, error) { ...@@ -365,6 +428,9 @@ func (p *PartitionChanges) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 22. StartOperation // 22. StartOperation
...@@ -373,6 +439,9 @@ func (p *StartOperation) NEODecode(data []byte) (int, error) { ...@@ -373,6 +439,9 @@ func (p *StartOperation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
p.Backup = byte2bool((data[0:])[0]) p.Backup = byte2bool((data[0:])[0])
return int(nread) + 1, nil return int(nread) + 1, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 23. StopOperation // 23. StopOperation
...@@ -380,6 +449,9 @@ func (p *StartOperation) NEODecode(data []byte) (int, error) { ...@@ -380,6 +449,9 @@ func (p *StartOperation) NEODecode(data []byte) (int, error) {
func (p *StopOperation) NEODecode(data []byte) (int, error) { func (p *StopOperation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 24. UnfinishedTransactions // 24. UnfinishedTransactions
...@@ -387,6 +459,9 @@ func (p *StopOperation) NEODecode(data []byte) (int, error) { ...@@ -387,6 +459,9 @@ func (p *StopOperation) NEODecode(data []byte) (int, error) {
func (p *UnfinishedTransactions) NEODecode(data []byte) (int, error) { func (p *UnfinishedTransactions) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 25. AnswerUnfinishedTransactions // 25. AnswerUnfinishedTransactions
...@@ -407,6 +482,9 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) { ...@@ -407,6 +482,9 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 26. LockedTransactions // 26. LockedTransactions
...@@ -414,6 +492,9 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) { ...@@ -414,6 +492,9 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
func (p *LockedTransactions) NEODecode(data []byte) (int, error) { func (p *LockedTransactions) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 27. AnswerLockedTransactions // 27. AnswerLockedTransactions
...@@ -434,6 +515,9 @@ func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) { ...@@ -434,6 +515,9 @@ func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 28. FinalTID // 28. FinalTID
...@@ -442,6 +526,9 @@ func (p *FinalTID) NEODecode(data []byte) (int, error) { ...@@ -442,6 +526,9 @@ func (p *FinalTID) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 29. AnswerFinalTID // 29. AnswerFinalTID
...@@ -450,6 +537,9 @@ func (p *AnswerFinalTID) NEODecode(data []byte) (int, error) { ...@@ -450,6 +537,9 @@ func (p *AnswerFinalTID) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 30. ValidateTransaction // 30. ValidateTransaction
...@@ -459,6 +549,9 @@ func (p *ValidateTransaction) NEODecode(data []byte) (int, error) { ...@@ -459,6 +549,9 @@ func (p *ValidateTransaction) NEODecode(data []byte) (int, error) {
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 31. BeginTransaction // 31. BeginTransaction
...@@ -467,6 +560,9 @@ func (p *BeginTransaction) NEODecode(data []byte) (int, error) { ...@@ -467,6 +560,9 @@ func (p *BeginTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 32. AnswerBeginTransaction // 32. AnswerBeginTransaction
...@@ -475,6 +571,9 @@ func (p *AnswerBeginTransaction) NEODecode(data []byte) (int, error) { ...@@ -475,6 +571,9 @@ func (p *AnswerBeginTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 33. FinishTransaction // 33. FinishTransaction
...@@ -507,6 +606,9 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) { ...@@ -507,6 +606,9 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 34. AnswerFinishTransaction // 34. AnswerFinishTransaction
...@@ -516,6 +618,9 @@ func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) { ...@@ -516,6 +618,9 @@ func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) {
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 35. NotifyTransactionFinished // 35. NotifyTransactionFinished
...@@ -525,6 +630,9 @@ func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) { ...@@ -525,6 +630,9 @@ func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) {
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 36. LockInformation // 36. LockInformation
...@@ -534,6 +642,9 @@ func (p *LockInformation) NEODecode(data []byte) (int, error) { ...@@ -534,6 +642,9 @@ func (p *LockInformation) NEODecode(data []byte) (int, error) {
p.Ttid = Tid(binary.BigEndian.Uint64(data[0:])) p.Ttid = Tid(binary.BigEndian.Uint64(data[0:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 37. AnswerLockInformation // 37. AnswerLockInformation
...@@ -542,6 +653,9 @@ func (p *AnswerLockInformation) NEODecode(data []byte) (int, error) { ...@@ -542,6 +653,9 @@ func (p *AnswerLockInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 38. InvalidateObjects // 38. InvalidateObjects
...@@ -562,6 +676,9 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) { ...@@ -562,6 +676,9 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 39. UnlockInformation // 39. UnlockInformation
...@@ -570,6 +687,9 @@ func (p *UnlockInformation) NEODecode(data []byte) (int, error) { ...@@ -570,6 +687,9 @@ func (p *UnlockInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 40. GenerateOIDs // 40. GenerateOIDs
...@@ -578,6 +698,9 @@ func (p *GenerateOIDs) NEODecode(data []byte) (int, error) { ...@@ -578,6 +698,9 @@ func (p *GenerateOIDs) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
p.NumOIDs = binary.BigEndian.Uint32(data[0:]) p.NumOIDs = binary.BigEndian.Uint32(data[0:])
return int(nread) + 4, nil return int(nread) + 4, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 41. AnswerGenerateOIDs // 41. AnswerGenerateOIDs
...@@ -597,6 +720,9 @@ func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) { ...@@ -597,6 +720,9 @@ func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 42. StoreObject // 42. StoreObject
...@@ -642,6 +768,9 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) { ...@@ -642,6 +768,9 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) {
p.Tid = Tid(binary.BigEndian.Uint64(data[8:])) p.Tid = Tid(binary.BigEndian.Uint64(data[8:]))
p.Unlock = byte2bool((data[16:])[0]) p.Unlock = byte2bool((data[16:])[0])
return int(nread) + 17, nil return int(nread) + 17, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 43. AnswerStoreObject // 43. AnswerStoreObject
...@@ -652,6 +781,9 @@ func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) { ...@@ -652,6 +781,9 @@ func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) {
p.Oid = Oid(binary.BigEndian.Uint64(data[1:])) p.Oid = Oid(binary.BigEndian.Uint64(data[1:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 44. AbortTransaction // 44. AbortTransaction
...@@ -660,6 +792,9 @@ func (p *AbortTransaction) NEODecode(data []byte) (int, error) { ...@@ -660,6 +792,9 @@ func (p *AbortTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 45. StoreTransaction // 45. StoreTransaction
...@@ -671,7 +806,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -671,7 +806,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.User = string(data[:l]) p.User = string(data[:l])
data = data[l:] data = data[l:]
...@@ -681,7 +816,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -681,7 +816,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Description = string(data[:l]) p.Description = string(data[:l])
data = data[l:] data = data[l:]
...@@ -691,7 +826,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -691,7 +826,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Extension = string(data[:l]) p.Extension = string(data[:l])
data = data[l:] data = data[l:]
...@@ -710,6 +845,9 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -710,6 +845,9 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 46. VoteTransaction // 46. VoteTransaction
...@@ -718,6 +856,9 @@ func (p *VoteTransaction) NEODecode(data []byte) (int, error) { ...@@ -718,6 +856,9 @@ func (p *VoteTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 47. GetObject // 47. GetObject
...@@ -728,6 +869,9 @@ func (p *GetObject) NEODecode(data []byte) (int, error) { ...@@ -728,6 +869,9 @@ func (p *GetObject) NEODecode(data []byte) (int, error) {
p.Serial = Tid(binary.BigEndian.Uint64(data[8:])) p.Serial = Tid(binary.BigEndian.Uint64(data[8:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 48. AnswerGetObject // 48. AnswerGetObject
...@@ -772,6 +916,9 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) { ...@@ -772,6 +916,9 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
} }
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
overflow:
return 0, ErrDecodeOverflow
} }
// 49. TIDList // 49. TIDList
...@@ -782,6 +929,9 @@ func (p *TIDList) NEODecode(data []byte) (int, error) { ...@@ -782,6 +929,9 @@ func (p *TIDList) NEODecode(data []byte) (int, error) {
p.Last = binary.BigEndian.Uint64(data[8:]) p.Last = binary.BigEndian.Uint64(data[8:])
p.Partition = binary.BigEndian.Uint32(data[16:]) p.Partition = binary.BigEndian.Uint32(data[16:])
return int(nread) + 20, nil return int(nread) + 20, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 50. AnswerTIDList // 50. AnswerTIDList
...@@ -801,6 +951,9 @@ func (p *AnswerTIDList) NEODecode(data []byte) (int, error) { ...@@ -801,6 +951,9 @@ func (p *AnswerTIDList) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 51. TIDListFrom // 51. TIDListFrom
...@@ -812,6 +965,9 @@ func (p *TIDListFrom) NEODecode(data []byte) (int, error) { ...@@ -812,6 +965,9 @@ func (p *TIDListFrom) NEODecode(data []byte) (int, error) {
p.Length = binary.BigEndian.Uint32(data[16:]) p.Length = binary.BigEndian.Uint32(data[16:])
p.Partition = binary.BigEndian.Uint32(data[20:]) p.Partition = binary.BigEndian.Uint32(data[20:])
return int(nread) + 24, nil return int(nread) + 24, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 52. AnswerTIDListFrom // 52. AnswerTIDListFrom
...@@ -831,6 +987,9 @@ func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) { ...@@ -831,6 +987,9 @@ func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 53. TransactionInformation // 53. TransactionInformation
...@@ -839,6 +998,9 @@ func (p *TransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -839,6 +998,9 @@ func (p *TransactionInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 54. AnswerTransactionInformation // 54. AnswerTransactionInformation
...@@ -850,7 +1012,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -850,7 +1012,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.User = string(data[:l]) p.User = string(data[:l])
data = data[l:] data = data[l:]
...@@ -860,7 +1022,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -860,7 +1022,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Description = string(data[:l]) p.Description = string(data[:l])
data = data[l:] data = data[l:]
...@@ -870,7 +1032,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -870,7 +1032,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Extension = string(data[:l]) p.Extension = string(data[:l])
data = data[l:] data = data[l:]
...@@ -890,6 +1052,9 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -890,6 +1052,9 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 55. ObjectHistory // 55. ObjectHistory
...@@ -900,6 +1065,9 @@ func (p *ObjectHistory) NEODecode(data []byte) (int, error) { ...@@ -900,6 +1065,9 @@ func (p *ObjectHistory) NEODecode(data []byte) (int, error) {
p.First = binary.BigEndian.Uint64(data[8:]) p.First = binary.BigEndian.Uint64(data[8:])
p.Last = binary.BigEndian.Uint64(data[16:]) p.Last = binary.BigEndian.Uint64(data[16:])
return int(nread) + 24, nil return int(nread) + 24, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 56. AnswerObjectHistory // 56. AnswerObjectHistory
...@@ -924,6 +1092,9 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) { ...@@ -924,6 +1092,9 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 57. PartitionList // 57. PartitionList
...@@ -934,6 +1105,9 @@ func (p *PartitionList) NEODecode(data []byte) (int, error) { ...@@ -934,6 +1105,9 @@ func (p *PartitionList) NEODecode(data []byte) (int, error) {
p.MaxOffset = binary.BigEndian.Uint32(data[4:]) p.MaxOffset = binary.BigEndian.Uint32(data[4:])
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
overflow:
return 0, ErrDecodeOverflow
} }
// 58. AnswerPartitionList // 58. AnswerPartitionList
...@@ -967,6 +1141,9 @@ func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) { ...@@ -967,6 +1141,9 @@ func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 59. X_NodeList // 59. X_NodeList
...@@ -975,6 +1152,9 @@ func (p *X_NodeList) NEODecode(data []byte) (int, error) { ...@@ -975,6 +1152,9 @@ func (p *X_NodeList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 60. AnswerNodeList // 60. AnswerNodeList
...@@ -993,7 +1173,7 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) { ...@@ -993,7 +1173,7 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
(*a).Address.Host = string(data[:l]) (*a).Address.Host = string(data[:l])
data = data[l:] data = data[l:]
...@@ -1008,6 +1188,9 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) { ...@@ -1008,6 +1188,9 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 61. SetNodeState // 61. SetNodeState
...@@ -1017,6 +1200,9 @@ func (p *SetNodeState) NEODecode(data []byte) (int, error) { ...@@ -1017,6 +1200,9 @@ func (p *SetNodeState) NEODecode(data []byte) (int, error) {
p.UUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) p.UUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 62. AddPendingNodes // 62. AddPendingNodes
...@@ -1036,6 +1222,9 @@ func (p *AddPendingNodes) NEODecode(data []byte) (int, error) { ...@@ -1036,6 +1222,9 @@ func (p *AddPendingNodes) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 63. TweakPartitionTable // 63. TweakPartitionTable
...@@ -1055,6 +1244,9 @@ func (p *TweakPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -1055,6 +1244,9 @@ func (p *TweakPartitionTable) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 64. NotifyNodeInformation // 64. NotifyNodeInformation
...@@ -1073,7 +1265,7 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) { ...@@ -1073,7 +1265,7 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
(*a).Address.Host = string(data[:l]) (*a).Address.Host = string(data[:l])
data = data[l:] data = data[l:]
...@@ -1088,6 +1280,9 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) { ...@@ -1088,6 +1280,9 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 65. NodeInformation // 65. NodeInformation
...@@ -1095,6 +1290,9 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) { ...@@ -1095,6 +1290,9 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) {
func (p *NodeInformation) NEODecode(data []byte) (int, error) { func (p *NodeInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 66. SetClusterState // 66. SetClusterState
...@@ -1103,6 +1301,9 @@ func (p *SetClusterState) NEODecode(data []byte) (int, error) { ...@@ -1103,6 +1301,9 @@ func (p *SetClusterState) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 67. ClusterInformation // 67. ClusterInformation
...@@ -1111,6 +1312,9 @@ func (p *ClusterInformation) NEODecode(data []byte) (int, error) { ...@@ -1111,6 +1312,9 @@ func (p *ClusterInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 68. X_ClusterState // 68. X_ClusterState
...@@ -1119,6 +1323,9 @@ func (p *X_ClusterState) NEODecode(data []byte) (int, error) { ...@@ -1119,6 +1323,9 @@ func (p *X_ClusterState) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 69. ObjectUndoSerial // 69. ObjectUndoSerial
...@@ -1141,6 +1348,9 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) { ...@@ -1141,6 +1348,9 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 70. AnswerObjectUndoSerial // 70. AnswerObjectUndoSerial
...@@ -1173,6 +1383,9 @@ func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) { ...@@ -1173,6 +1383,9 @@ func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 71. HasLock // 71. HasLock
...@@ -1182,6 +1395,9 @@ func (p *HasLock) NEODecode(data []byte) (int, error) { ...@@ -1182,6 +1395,9 @@ func (p *HasLock) NEODecode(data []byte) (int, error) {
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 72. AnswerHasLock // 72. AnswerHasLock
...@@ -1191,6 +1407,9 @@ func (p *AnswerHasLock) NEODecode(data []byte) (int, error) { ...@@ -1191,6 +1407,9 @@ func (p *AnswerHasLock) NEODecode(data []byte) (int, error) {
p.Oid = Oid(binary.BigEndian.Uint64(data[0:])) p.Oid = Oid(binary.BigEndian.Uint64(data[0:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 73. CheckCurrentSerial // 73. CheckCurrentSerial
...@@ -1201,6 +1420,9 @@ func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) { ...@@ -1201,6 +1420,9 @@ func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) {
p.Serial = Tid(binary.BigEndian.Uint64(data[8:])) p.Serial = Tid(binary.BigEndian.Uint64(data[8:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 74. AnswerCheckCurrentSerial // 74. AnswerCheckCurrentSerial
...@@ -1211,6 +1433,9 @@ func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) { ...@@ -1211,6 +1433,9 @@ func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) {
p.Oid = Oid(binary.BigEndian.Uint64(data[1:])) p.Oid = Oid(binary.BigEndian.Uint64(data[1:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 75. Pack // 75. Pack
...@@ -1219,6 +1444,9 @@ func (p *Pack) NEODecode(data []byte) (int, error) { ...@@ -1219,6 +1444,9 @@ func (p *Pack) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 76. AnswerPack // 76. AnswerPack
...@@ -1227,6 +1455,9 @@ func (p *AnswerPack) NEODecode(data []byte) (int, error) { ...@@ -1227,6 +1455,9 @@ func (p *AnswerPack) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
p.Status = byte2bool((data[0:])[0]) p.Status = byte2bool((data[0:])[0])
return int(nread) + 1, nil return int(nread) + 1, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 77. CheckReplicas // 77. CheckReplicas
...@@ -1249,6 +1480,9 @@ func (p *CheckReplicas) NEODecode(data []byte) (int, error) { ...@@ -1249,6 +1480,9 @@ func (p *CheckReplicas) NEODecode(data []byte) (int, error) {
p.MinTID = Tid(binary.BigEndian.Uint64(data[0:])) p.MinTID = Tid(binary.BigEndian.Uint64(data[0:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 78. CheckPartition // 78. CheckPartition
...@@ -1260,7 +1494,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) { ...@@ -1260,7 +1494,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Source.UpstreamName = string(data[:l]) p.Source.UpstreamName = string(data[:l])
data = data[l:] data = data[l:]
...@@ -1270,7 +1504,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) { ...@@ -1270,7 +1504,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
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 {
return 0, ErrDecodeOverflow goto overflow
} }
p.Source.Address.Host = string(data[:l]) p.Source.Address.Host = string(data[:l])
data = data[l:] data = data[l:]
...@@ -1280,6 +1514,9 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) { ...@@ -1280,6 +1514,9 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
p.MinTID = Tid(binary.BigEndian.Uint64(data[2:])) p.MinTID = Tid(binary.BigEndian.Uint64(data[2:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 79. CheckTIDRange // 79. CheckTIDRange
...@@ -1291,6 +1528,9 @@ func (p *CheckTIDRange) NEODecode(data []byte) (int, error) { ...@@ -1291,6 +1528,9 @@ func (p *CheckTIDRange) NEODecode(data []byte) (int, error) {
p.MinTID = Tid(binary.BigEndian.Uint64(data[8:])) p.MinTID = Tid(binary.BigEndian.Uint64(data[8:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 80. AnswerCheckTIDRange // 80. AnswerCheckTIDRange
...@@ -1320,6 +1560,9 @@ func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) { ...@@ -1320,6 +1560,9 @@ func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) {
p.Checksum[19] = (data[23:])[0] p.Checksum[19] = (data[23:])[0]
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
overflow:
return 0, ErrDecodeOverflow
} }
// 81. CheckSerialRange // 81. CheckSerialRange
...@@ -1332,6 +1575,9 @@ func (p *CheckSerialRange) NEODecode(data []byte) (int, error) { ...@@ -1332,6 +1575,9 @@ func (p *CheckSerialRange) NEODecode(data []byte) (int, error) {
p.MaxTID = Tid(binary.BigEndian.Uint64(data[16:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[16:]))
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
overflow:
return 0, ErrDecodeOverflow
} }
// 82. AnswerCheckSerialRange // 82. AnswerCheckSerialRange
...@@ -1382,6 +1628,9 @@ func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) { ...@@ -1382,6 +1628,9 @@ func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) {
p.OidChecksum[19] = (data[51:])[0] p.OidChecksum[19] = (data[51:])[0]
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
overflow:
return 0, ErrDecodeOverflow
} }
// 83. PartitionCorrupted // 83. PartitionCorrupted
...@@ -1402,6 +1651,9 @@ func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) { ...@@ -1402,6 +1651,9 @@ func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) {
} }
} }
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 84. LastTransaction // 84. LastTransaction
...@@ -1409,6 +1661,9 @@ func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) { ...@@ -1409,6 +1661,9 @@ func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) {
func (p *LastTransaction) NEODecode(data []byte) (int, error) { func (p *LastTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
// 85. AnswerLastTransaction // 85. AnswerLastTransaction
...@@ -1417,6 +1672,9 @@ func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) { ...@@ -1417,6 +1672,9 @@ func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
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
overflow:
return 0, ErrDecodeOverflow
} }
// 86. NotifyReady // 86. NotifyReady
...@@ -1424,4 +1682,7 @@ func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) { ...@@ -1424,4 +1682,7 @@ func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) {
func (p *NotifyReady) NEODecode(data []byte) (int, error) { func (p *NotifyReady) NEODecode(data []byte) (int, error) {
var nread uint32 var nread uint32
return int(nread) + 0, nil return int(nread) + 0, nil
overflow:
return 0, ErrDecodeOverflow
} }
...@@ -201,7 +201,7 @@ func (d *decoder) decodeStrBytes(assignto string) { ...@@ -201,7 +201,7 @@ func (d *decoder) decodeStrBytes(assignto string) {
d.emit("{") d.emit("{")
d.decodeBasic("l:", types.Typ[types.Uint32], nil, nil) d.decodeBasic("l:", types.Typ[types.Uint32], nil, nil)
d.emit("data = data[%v:]", d.n) d.emit("data = data[%v:]", d.n)
d.emit("if uint32(len(data)) < l { return 0, ErrDecodeOverflow }") d.emit("if uint32(len(data)) < l { goto overflow }")
d.emit("%v= string(data[:l])", assignto) d.emit("%v= string(data[:l])", assignto)
d.emit("data = data[l:]") d.emit("data = data[l:]")
d.emit("nread += %v + l", d.n) d.emit("nread += %v + l", d.n)
...@@ -221,7 +221,7 @@ func (d *decoder) decodeSlice(assignto string, typ *types.Slice, obj types.Objec ...@@ -221,7 +221,7 @@ func (d *decoder) decodeSlice(assignto string, typ *types.Slice, obj types.Objec
d.emit("%v= make(%v, l)", assignto, typeName(typ)) d.emit("%v= make(%v, l)", assignto, typeName(typ))
// TODO size check // TODO size check
// TODO if size(item)==const - check l in one go // TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }") //d.emit("if len(data) < l { goto overflow }")
d.emit("for i := 0; uint32(i) < l; i++ {") d.emit("for i := 0; uint32(i) < l; i++ {")
d.emit("a := &%s[i]", assignto) d.emit("a := &%s[i]", assignto)
// XXX try to avoid (*) in a // XXX try to avoid (*) in a
...@@ -245,7 +245,7 @@ func (d *decoder) decodeMap(assignto string, typ *types.Map, obj types.Object) { ...@@ -245,7 +245,7 @@ func (d *decoder) decodeMap(assignto string, typ *types.Map, obj types.Object) {
d.emit("%v= make(%v, l)", assignto, typeName(typ)) d.emit("%v= make(%v, l)", assignto, typeName(typ))
// TODO size check // TODO size check
// TODO if size(item)==const - check l in one go // TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }") //d.emit("if len(data) < l { goto overflow }")
d.emit("m := %v", assignto) d.emit("m := %v", assignto)
d.emit("for i := 0; uint32(i) < l; i++ {") d.emit("for i := 0; uint32(i) < l; i++ {")
d.decodeType("key:", typ.Key(), obj) d.decodeType("key:", typ.Key(), obj)
...@@ -335,6 +335,8 @@ func gendecode(typespec *ast.TypeSpec) string { ...@@ -335,6 +335,8 @@ func gendecode(typespec *ast.TypeSpec) string {
d.decodeType("p", typ, obj) d.decodeType("p", typ, obj)
d.emit("return int(nread) + %v, nil", d.n) d.emit("return int(nread) + %v, nil", d.n)
d.emit("\noverflow:")
d.emit("return 0, ErrDecodeOverflow")
d.emit("}") d.emit("}")
return d.buf.String() return d.buf.String()
} }
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