samba-bugs@samba.org
2008-Oct-24 17:59 UTC
DO NOT REPLY [Bug 5851] New: Name lookup failures and CIDR regression
https://bugzilla.samba.org/show_bug.cgi?id=5851 Summary: Name lookup failures and CIDR regression Product: rsync Version: 3.0.4 Platform: All OS/Version: Windows XP Status: NEW Severity: major Priority: P3 Component: core AssignedTo: wayned@samba.org ReportedBy: steven.hartland@multiplay.co.uk QAContact: rsync-qa@samba.org Just updated to 3.0.4 under cygwin and I'm now getting lookup failures in the log. 2008/10/24 00:13:23 [1984] name lookup failed for X.X.X.X: Unknown server error Looking at the code it seems the call will never succeed? /* reverse lookup */ name_err = getnameinfo((struct sockaddr *) ss, ss_len, name_buf, name_buf_size, port_buf, port_buf_size, NI_NAMEREQD | NI_NUMERICSERV); if (name_err != 0) { strlcpy(name_buf, default_name, name_buf_size); rprintf(FLOG, "name lookup failed for %s: %s\n", client_addr(fd), gai_strerror(name_err)); return name_err; } Then in the supplied getnameinfo:- /* We don't support those. */ if ((node && !(flags & NI_NUMERICHOST)) || (service && !(flags & NI_NUMERICSERV))) return EAI_FAIL; if (node) { return gethostnameinfo(sa, node, nodelen, flags); } if (service) { return getservicenameinfo(sa, service, servicelen, flags); } return 0; There seems to be three issues here:- 1. Both name ( node ) and port ( service ) are passed in but NI_NUMERICHOST is not supplied so the call will always return EAI_FAIL due to the "We don't support those" check. 2. getnameinfo returns early without completing the service lookup, if node information is requested in addition to service info. 3. The "don't support these" check is totally invalid as the code does actually appear support both these types requests as far as I can see. Given the above I believe the fix is to remove the following block totally:- /* We don't support those. */ if ((node && !(flags & NI_NUMERICHOST)) || (service && !(flags & NI_NUMERICSERV))) return EAI_FAIL; And update the remaining block to:- if (node) { int ret = gethostnameinfo(sa, node, nodelen, flags); if (0 != ret) { return ret; } } if (service) { return getservicenameinfo(sa, service, servicelen, flags); } Next up is allow hosts CIDR notation seems to have been broken. This looks like a really old regression caused by the following commit:- http://git.samba.org/?p=rsync.git;a=commitdiff;h=bc2b4963a009dd8194b2e9f996a63b9c634a6263 The fix is fairly trivial:- if ( ! strchr(p,'.')) { // CIDR notation int bits = atoi(p+1); if (bits == 0) return 1; if (bits <= 0 || bits > 32) { rprintf(FLOG,"malformed mask in %s\n", tok); return 0; } } else if (inet_pton(resa->ai_addr->sa_family, p, mask) <= 0) { // Dot notation ( netmask ) -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug, or are watching the QA contact.
samba-bugs@samba.org
2008-Oct-24 18:00 UTC
DO NOT REPLY [Bug 5851] Name lookup failures and CIDR regression
https://bugzilla.samba.org/show_bug.cgi?id=5851 ------- Comment #1 from steven.hartland@multiplay.co.uk 2008-10-24 13:00 CST ------- Created an attachment (id=3686) --> (https://bugzilla.samba.org/attachment.cgi?id=3686&action=view) Patch to fix the issue -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug, or are watching the QA contact.
samba-bugs@samba.org
2008-Oct-25 15:19 UTC
DO NOT REPLY [Bug 5851] Name lookup failures and CIDR regression
https://bugzilla.samba.org/show_bug.cgi?id=5851 wayned@samba.org changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #3686 is|1 |0 patch| | -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug, or are watching the QA contact.
samba-bugs@samba.org
2008-Oct-25 15:20 UTC
DO NOT REPLY [Bug 5851] Name lookup failures and CIDR regression
https://bugzilla.samba.org/show_bug.cgi?id=5851 wayned@samba.org changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #3686|text/plain |application/zip mime type| | -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug, or are watching the QA contact.
https://bugzilla.samba.org/show_bug.cgi?id=5851 wayned@samba.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Summary|Name lookup failures and |Name lookup failures |CIDR regression | ------- Comment #2 from wayned@samba.org 2008-10-25 11:23 CST ------- I have applied your fix to lib/getaddrinfo.c -- much appreciated! The change to access.c is not needed, though, as the code right after your insertion is the code that handles CIDR notation. A value such as "16" passed to inet_pton() should return back a 0, since it does not have the required format for either an IPv4 or IPv6 address. If cygwin is returning a positive value, you can use the version of inet_pton() provided by the lib/inet_pton.c file (and report the error to the cygwin folks). Thanks for your report! -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug, or are watching the QA contact.
https://bugzilla.samba.org/show_bug.cgi?id=5851 ------- Comment #3 from steven.hartland@multiplay.co.uk 2008-10-25 13:06 CST ------- Confirmed inet_pton when passed "24" for x.x.x.x/24 is returning 1 and hence causing the issue. Forcing the use of lib/inet_pton.c fixed this. -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug, or are watching the QA contact.