p2p: fix array out of bounds issue (#23165)

This commit is contained in:
Evolution404 2021-07-06 15:33:51 +08:00 committed by GitHub
parent bd566977e8
commit 5afc82de6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,7 +89,7 @@ var discReasonToString = [...]string{
}
func (d DiscReason) String() string {
if len(discReasonToString) < int(d) {
if len(discReasonToString) <= int(d) {
return fmt.Sprintf("unknown disconnect reason %d", d)
}
return discReasonToString[d]