Skip to content

Commit

Permalink
check udp header size to prevent crashing for older bepass versions
Browse files Browse the repository at this point in the history
  • Loading branch information
uoosef committed Sep 30, 2023
1 parent 5083af8 commit c2d3e82
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func handleUDPOverTCP(conn net.Conn, destination string) {
for {
select {
case dataFromWS := <-wsReadDataChan:
if dataFromWS == nil {
if dataFromWS == nil || len(dataFromWS) < 8 {
return
}
if udpWriteChan, err := getOrCreateUDPChan(destination, string(dataFromWS[:8])); err == nil {
Expand Down Expand Up @@ -81,6 +81,9 @@ func getOrCreateUDPChan(destination, header string) (chan []byte, error) {
for {
select {
case dataFromWS := <-udpToTCPChannels[channelID]:
if len(dataFromWS) < 8 {
return
}
_, err := udpConn.Write(dataFromWS[8:])
if err != nil {
return
Expand Down

0 comments on commit c2d3e82

Please sign in to comment.