Bug 12660

Summary: Fix for gethostbyname2() problem when using socks5
Product: Ports & Packages Reporter: Andre Albsmeier <Andre.Albsmeier>
Component: Individual Port(s)Assignee: Warner Losh <imp>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Andre Albsmeier 1999-07-16 09:00:01 UTC
When trying to socksify (with runsocks) a program that uses gethostbyname2(),
sometimes the program fails. This is due to the following reason:

1. the program calls gethostbyname2() which is not socksified
2. gethostbyname2() starts his work and calls other functions
   that are socksified (e.g. sendto)
3. sendto (from the sockslib) now starts its work and, as part of
   that, itself does a gethostbyname().
4. gethostbyname() from libc does nothing more than calling gethostbyname2().
5. Now we have entered gethostbyname2() again and that fails...

Fix: I have tried to implement the gethostbyname2() call the same way as
gethostbyname() is done in the sockslib. In case socks5 is configured to
fake DNS calls, we call the daemon if the af argument is AF_INET. If
we don't fake DNS calls, we call the original gethostbyname2() function.

How-To-Repeat: 
As I said above, the program not always fails. I can make it fail
here when I have only one nameserver in /etc/resolv.conf. With three
nameservers (even if they are the same), it works. I could make
it fail by running "runsocks whois blahblah" with only one
nameserver in /etc/resolv.conf.
Comment 1 Steve Price freebsd_committer freebsd_triage 1999-08-01 03:17:35 UTC
Responsible Changed
From-To: freebsd-ports->imp

Over to maintainer. 

Comment 2 Andre Albsmeier 1999-08-05 08:07:26 UTC
This one can be closed. My patch has made it into the
new distribution, socks5-v1.0r10.

However, here is a note for the maintainer: It seems that
only the first part of patch-aa has made it into the distribution.
I think, second one is still needed but I can not confirm this
since I don't have any 2.x systems anymore...

	-Andre
Comment 3 Warner Losh freebsd_committer freebsd_triage 1999-09-25 06:49:40 UTC
State Changed
From-To: open->closed

This patch is in r10.  I've updated to r10.