Bug 233900 - Incorrect salen parameter being given to getnameinfo() causes all calls to fail
Summary: Incorrect salen parameter being given to getnameinfo() causes all calls to fail
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: dhcpv6
Version: 6
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: David Cantrell
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-03-25 17:26 UTC by Daniel Berrangé
Modified: 2007-11-30 22:12 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-03-26 15:01:57 UTC
Type: ---


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

Description Daniel Berrangé 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 Berrangé 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.


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