Bug 233900 - Incorrect salen parameter being given to getnameinfo() causes all calls to fail
Incorrect salen parameter being given to getnameinfo() causes all calls to fail
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: dhcpv6 (Show other bugs)
6
All Linux
medium Severity medium
: ---
: ---
Assigned To: David Cantrell
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-03-25 13:26 EDT by Daniel Berrange
Modified: 2007-11-30 17:12 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-03-26 11:01:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Pass in correct salen values to getnameinfo() (5.43 KB, patch)
2007-03-25 13:37 EDT, Daniel Berrange
no flags Details | Diff

  None (edit)
Description Daniel Berrange 2007-03-25 13:26:05 EDT
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 13:37:13 EDT
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 11:01:57 EDT
Thanks for the patch.  Included in dhcpv6-0.10-41.fc7.

Note You need to log in before you can comment on or make changes to this bug.