Skip to content

some panics in Server's handleAssociate #112

@actualben

Description

@actualben

https://github.com/things-go/go-socks5/blob/d12f6027afa1158d1645ade0c314b2eb863f6c9b/handle.go#L280C1-L280C101

I believe this code is producing the following panics that I'm seeing:

panic: runtime error: invalid memory address or nil pointer dereference
 [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x6c3542]
 
 goroutine 651 [running]:
 github.com/things-go/go-socks5.(*Server).handleAssociate.func2.2()
 	github.com/things-go/go-socks5@v0.1.0/handle.go:280 +0x4e2
 created by github.com/things-go/go-socks5.(*Server).goFunc in goroutine 130
 	github.com/things-go/go-socks5@v0.1.0/server.go:200 +0x3e
 panic: runtime error: invalid memory address or nil pointer dereference
 [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x6c3542]
 
 goroutine 675 [running]:
 github.com/things-go/go-socks5.(*Server).handleAssociate.func2.2()
 	github.com/things-go/go-socks5@v0.1.0/handle.go:280 +0x4e2
 created by github.com/things-go/go-socks5.(*Server).goFunc in goroutine 130
 	github.com/things-go/go-socks5@v0.1.0/server.go:200 +0x3e
 panic: runtime error: invalid memory address or nil pointer dereference
 [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x6c3542]
 
 goroutine 781 [running]:
 github.com/things-go/go-socks5.(*Server).handleAssociate.func2.2()
 	github.com/things-go/go-socks5@v0.1.0/handle.go:280 +0x4e2
 created by github.com/things-go/go-socks5.(*Server).goFunc in goroutine 130
 	github.com/things-go/go-socks5@v0.1.0/server.go:200 +0x3e

So when RemoteAddr() is nil (which happens), calling .String() causes the panic.

The same issue exists elsewhere in this function too:

  • targetNew.RemoteAddr().String() in the write-error log
  • target.(net.Conn).RemoteAddr().String() in the else branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions