Skip to content

Commit

Permalink
Add check for stats vector length (#172)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
  • Loading branch information
glazychev-art committed Dec 11, 2023
1 parent 6c46a64 commit 78069e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions adapter/statsclient/statseg_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ func (ss *statSegmentV2) UpdateEntryData(segment dirSegment, stat *adapter.Stat)
}
vecLen := *(*uint32)(vectorLen(dirVector))
data := (*stat).(adapter.CombinedCounterStat)
if uint32(len(data)) != vecLen {
return ErrStatDataLenIncorrect
}
for i := uint32(0); i < vecLen; i++ {
counterVectorOffset := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0)))
counterVector := ss.adjust(vectorLen(counterVectorOffset))
Expand All @@ -339,6 +342,9 @@ func (ss *statSegmentV2) UpdateEntryData(segment dirSegment, stat *adapter.Stat)
}
vecLen := *(*uint32)(vectorLen(dirVector))
data := (*stat).(adapter.NameStat)
if uint32(len(data)) != vecLen {
return ErrStatDataLenIncorrect
}
for i := uint32(0); i < vecLen; i++ {
nameVectorOffset := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0)))
if uintptr(nameVectorOffset) == 0 {
Expand Down

0 comments on commit 78069e4

Please sign in to comment.