Bug 1921 - gethostbyaddr does not fill in address
Summary: gethostbyaddr does not fill in address
Status: RESOLVED FIXED
Alias: None
Product: uClibc
Classification: Unclassified
Component: Networking (show other bugs)
Version: 0.9.31
Hardware: PC Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-03 05:01 UTC by Michael Deutschmann
Modified: 2011-01-11 19:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Patch to fix gethostbyaddr() problem (479 bytes, application/octet-stream)
2010-06-03 05:01 UTC, Michael Deutschmann
Details

Note You need to log in before you can comment on or make changes to this bug.
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!