Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 233900

Summary: Incorrect salen parameter being given to getnameinfo() causes all calls to fail
Product: [Fedora] Fedora Reporter: Daniel Berrange <berrange>
Component: dhcpv6Assignee: David Cantrell <dcantrell>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-03-26 15:01:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
Pass in correct salen values to getnameinfo() none

Description Daniel Berrange 2007-03-25 17:26:05 UTC
Description of problem:
If I run either the dhcp6c client or the dhcp6s server it logs multiple messages
saying calls to getnameinfo() are failing. eg

# dhcp6s -c /etc/dhcp6s.conf -f
Mar/25/2007 13:16:02  getnameinfo return error
Mar/25/2007 13:16:02  getnameinfo return error
Mar/25/2007 13:16:02  getnameinfo return error
Mar/25/2007 13:16:02  getnameinfo return error
Mar/25/2007 13:16:02  getnameinfo return error
Mar/25/2007 13:16:02  getnameinfo return error
Mar/25/2007 13:16:02  getnameinfo return error

Or

# dhcp6c  -f ath0
Mar/25/2007 13:18:07  getnameinfo return error
Mar/25/2007 13:18:07  getnameinfo return error
Mar/25/2007 13:18:07  getnameinfo return error
Mar/25/2007 13:18:07  getnameinfo return error
Mar/25/2007 13:18:07  getnameinfo return error
Mar/25/2007 13:18:07  getnameinfo return error
Mar/25/2007 13:18:07  getnameinfo return error
Mar/25/2007 13:18:07  getnameinfo return error



Version-Release number of selected component (if applicable):
dhcpv6-0.10-32.fc6

How reproducible:
Always

Steps to Reproduce:
1. Start dhcp6s on a server
2. Start dhcp6c on a client
3. Wait for client to initiate request with server
  
Actual results:
Multiple messages about getnameinfo() failing are printed

Expected results:
No getnameinfo() calls fail

Additional info:
The code has a systematic error in the way it calls getnameinfo(). The man page
documents the contract as

      int getnameinfo(const struct sockaddr *sa, socklen_t salen,
                       char *host, size_t hostlen,
                       char *serv, size_t servlen, int flags);


"The sa argument is a pointer to a generic socket address  structure 
 (of  type  sockaddr_in or sockaddr_in6) of size salen that holds the
 input IP address and port number."

In other words  salen  should basically be  sizeof(*sa).

The dhcp6s/dhcp6c code, however, is nearly always passing in
sizeof(*sa->sa_addr) which is too small. getnameinfo() checks the passed in
salen and determines that the sa buffer is not large enough to hold the IPv6
address and so returns a fail code.

There does not at first glance appear to be any operational ill-effects to the
DHCP server/client, but it makes the debug logs from these two programs utterly
useless because all the address info is missing.

Comment 1 Daniel Berrange 2007-03-25 17:37:13 UTC
Created attachment 150855 [details]
Pass in correct salen values to getnameinfo()

The attached patch fixes all the places which call getnameinfo() to pass in the
correct value for salen - ie sizeof(*sa) instead of sizeof(sa->sa_addr)

Comment 2 David Cantrell 2007-03-26 15:01:57 UTC
Thanks for the patch.  Included in dhcpv6-0.10-41.fc7.