fix checking number of arg before accessing it

This commit is contained in:
Shelikhoo 2024-05-13 16:02:01 +01:00 committed by WofWca
parent c0acdd7d2a
commit 15189aa5ac

View file

@ -244,6 +244,9 @@ func (handler *httpHandler) turboTunnelUDPLikeMode(conn net.Conn, addr net.Addr,
clientID := turbotunnel.ClientID{}
compoments := strings.Split(protocol, " ")
if len(compoments) != 2 {
return fmt.Errorf("invalid protocol: %s", protocol)
}
_, err := hex.Decode(clientID[:], []byte(compoments[1]))
if err != nil {
return fmt.Errorf("reading ClientID: %v", err)