Skip to content

Commit

Permalink
Fix of discreason type problem (#242)
Browse files Browse the repository at this point in the history
Problem: GHSA-wjxw-gh3m-7pm5

Fix: add non-negative `if` condition.

cannot use fix in geth (ethereum#24507) since modifying DiscReason to uint8 messes up the message encode
  • Loading branch information
wgr523 authored Mar 26, 2023
1 parent 21c54fd commit 436faf3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions p2p/peer_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ var discReasonToString = [...]string{
}

func (d DiscReason) String() string {
if len(discReasonToString) < int(d) {
if len(discReasonToString) <= int(d) || int(d) < 0 {
return fmt.Sprintf("unknown disconnect reason %d", d)
}
return discReasonToString[d]
return discReasonToString[int(d)]
}

func (d DiscReason) Error() string {
Expand Down

0 comments on commit 436faf3

Please sign in to comment.