Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix DOS attack from malicious pongs#291

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nhooyr merged 2 commits intomasterfromdos-56b8
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Fix DOS attack from malicious pongs
A double channel close panic was possible if a peer sent back multiplepongs for every ping.If the second pong arrived before the ping goroutine deleted its channelfrom the map, the channel would be closed twice and so a panic wouldensue.This fixes that by having the read goroutine send on the pinggoroutine's channel rather than closing it.Reported via email by Tibor Kálmán@kalmantPlease update to the new release ASAP!
  • Loading branch information
@nhooyr
nhooyr committedApr 7, 2021
commit129d3035f688f8f1c8a03d65e874e15860d21365
2 changes: 1 addition & 1 deletionconn_notjs.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,7 +189,7 @@ func (c *Conn) Ping(ctx context.Context) error {
}

func (c *Conn) ping(ctx context.Context, p string) error {
pong := make(chan struct{})
pong := make(chan struct{}, 1)

c.activePingsMu.Lock()
c.activePings[p] = pong
Expand Down
5 changes: 4 additions & 1 deletionread.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -271,7 +271,10 @@ func (c *Conn) handleControl(ctx context.Context, h header) (err error) {
pong, ok := c.activePings[string(b)]
c.activePingsMu.Unlock()
if ok {
close(pong)
select {
case pong <- struct{}{}:
default:
}
}
return nil
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp