Bug 1921

Summary: gethostbyaddr does not fill in address
Product: uClibc Reporter: Michael Deutschmann <michael>
Component: NetworkingAssignee: unassigned
Status: RESOLVED FIXED    
Severity: major CC: uclibc-cvs
Priority: P5    
Version: 0.9.31   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: Patch to fix gethostbyaddr() problem

Description Michael Deutschmann 2010-06-03 05:01:12 UTC
Created attachment 1873 [details]
Patch to fix gethostbyaddr() problem

gethostbyaddr returns a garbage address in the slot pointed to by h_addr_list.  This is a regression from 0.9.30.3.

While it is rather daft to do a gethostbyaddr lookup and then use that value (which is supposed to be the same as what was put in), NcFTP client is so perverted.  On an unpatched uClibc-0.9.31, it will appear to fail to connect to any host; what is really happening is that it is trying to open ftp connections to [0.0.0.0].

It appears the problem is a stray & operator in one line.  This causes the original address to be stored not in the intended slot, but over the pointer to that slot.  (In the IPv6 case, it appears stack corruption would also result.)

A fix is attached.
Comment 1 Bernhard Reutner-Fischer 2011-01-11 19:05:02 UTC
Fixed as 7f16871e1d09f10e94192781ae6b317537742131
Thanks!