dest-unreach / socat / contrib / socat-socks4a

Temporary fix for socat socks4a bug


See socks4.protocol and socks4a.protocol for protocol specifications. The socks4 protocol requires the client to resolve the target hostname while the newer socks4a protocol resolves the target host name on the socks server.

Due to a misunderstanding of the socks4a specification, socat constructed wrong socks4a request headers that were not recognized by socks servers. This bug has not been detected earlier for three reasons:
(1) socat development had no socks4a capable server at hand for testing
(2) socat's socks4a address implementation used socks4 and fell back to socks4a only when it could not resolve the hostname
(3) noone ever reported problems with socat's socks4a - probably due to (2)

With socat 1.4, (2) was changed: Now, socat's socks4a address does not try to use plain socks4 protocol but always uses the (buggy) socks4a implementation. Consequently, two users (Thomas Themel and Peter Palfrader) independently reported that bug and provided patches.

rik found that the original fix was buggy too, so please get the actual version, tagged with its release date!

Patch requisites

Apply this patch to socat source.

It does not conflict with socat-pty patch




This temporary fix is just a corrected xio-socks.c file. Uncompress it using gunzip and replace the old xio-socks.c file in socat-1.4 with this corrected version. Then rebuild socat:


This patch is integrated in socat and later.