Skip to content

Commit b16a5f0

Browse files
vemneyyFangliding
andauthored
Socks: Fix buffer full panic when encoding large UDP packets (#5252)
Co-authored-by: 风扇滑翔翼 <[email protected]>
1 parent 2f1fabb commit b16a5f0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

proxy/socks/protocol.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ func EncodeUDPPacket(request *protocol.RequestHeader, data []byte) (*buf.Buffer,
353353
b.Release()
354354
return nil, err
355355
}
356+
// if data is too large, return an empty buffer (drop too big data)
357+
if b.Available() < int32(len(data)) {
358+
b.Clear()
359+
return b, nil
360+
}
356361
common.Must2(b.Write(data))
357362
return b, nil
358363
}

0 commit comments

Comments
 (0)