We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7b3c380 commit b6778c5Copy full SHA for b6778c5
src/internal/poll/fd_unix.go
@@ -7,6 +7,7 @@
7
package poll
8
9
import (
10
+ "internal/itoa"
11
"internal/syscall/unix"
12
"io"
13
"sync/atomic"
@@ -379,6 +380,14 @@ func (fd *FD) Write(p []byte) (int, error) {
379
380
}
381
n, err := ignoringEINTRIO(syscall.Write, fd.Sysfd, p[nn:max])
382
if n > 0 {
383
+ if n > max-nn {
384
+ // This can reportedly happen when using
385
+ // some VPN software. Issue #61060.
386
+ // If we don't check this we will panic
387
+ // with slice bounds out of range.
388
+ // Use a more informative panic.
389
+ panic("invalid return from write: got " + itoa.Itoa(n) + " from a write of " + itoa.Itoa(max-nn))
390
+ }
391
nn += n
392
393
if nn == len(p) {
0 commit comments