Skip to content

Commit

Permalink
fix: NarrowMode rangeSpace uint8 overflow
Browse files Browse the repository at this point in the history
eg: 1.1.1.0-255
  • Loading branch information
XinRoom committed Mar 28, 2023
1 parent 40edb85 commit 57bbf32
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ func (it *Iter) incByIndex(index uint64) {
} else {
length := len(it.classmate)
ip := make([]byte, length)
rangeSpace := make([]uint8, length)
rangeSpace := make([]uint, length)
// 每一位的空间容量
for i, rangeMate := range it.classmate {
rangeSpace[i] = rangeMate.e - rangeMate.s + 1
rangeSpace[i] = uint(rangeMate.e-rangeMate.s) + 1
}
// transform 进位除余
carryBit := uint64(0) // 进位
Expand Down
2 changes: 1 addition & 1 deletion iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func TestName(t *testing.T) {
for _, v := range []string{"1.1.1.1", "1.1.1.2/30", "1.1.1.1-3", "1.1-2.0-1.4", "1.1.1.1-1.1.2.1", "2001::59:63", "2001::59:63/126", "2001::59:63-f2", "2001::59-60:63-f2", "2001::59:63-2001::59:f2"} {
for _, v := range []string{"1.1.1.1", "1.1.1.2/30", "1.1.1.0-255", "1.1-2.0-1.4", "1.1.1.1-1.1.2.1", "2001::59:63", "2001::59:63/126", "2001::59:63-f2", "2001::59-60:63-f2", "2001::59:63-2001::59:f2"} {
t.Logf("Test %s", v)
it, startIp, err := NewIter(v)
if err != nil {
Expand Down

0 comments on commit 57bbf32

Please sign in to comment.