Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update y.go #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update y.go #2

wants to merge 1 commit into from

Conversation

pic4xiu
Copy link

@pic4xiu pic4xiu commented Jun 14, 2023

If the mask entered by the user is greater than 32, it will return empty when calling net's CIDRMask, causing a panic when the program continues

❯ go run main.go
panic: runtime error: index out of range [3] with length 0

goroutine 1 [running]:
encoding/binary.bigEndian.Uint32(...)
        /usr/local/go/src/encoding/binary/binary.go:157
github.com/malfunkt/iprange.(*ipParserImpl).Parse(0x1400012e000, {0x1049143c8?, 0x14000120050?})
        yaccpar:351 +0x14bc
github.com/malfunkt/iprange.ipParse(...)
        yaccpar:153
github.com/malfunkt/iprange.ParseList({0x1048d3770?, 0x140000021a0?})
        ip.y:93 +0xa0
main.main()
        /Users/*/Desktop/sensor/bigdata/waf2/main.go:10 +0x28
exit status 2

I made a judgment after calling CIDRMask to generate the mask, and let it be limited to 32, so that when the user enters a value greater than 32, it will be automatically judged as 32. In this way, the program can avoid panic

Limit the mask to 32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant