Bug 11503 - Some interface configurations will core dump all samba utilities assertion in interfaces.c
Some interface configurations will core dump all samba utilities assertion in...
Status: NEW
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Other
4.2.3
All All
: P5 major
: ---
Assigned To: Andrew Bartlett
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-09 06:28 UTC by Ian West
Modified: 2015-09-09 08:54 UTC (History)
1 user (show)

See Also:


Attachments
Patches for ./lib/socket/interfaces.c (639 bytes, text/plain)
2015-09-09 06:28 UTC, Ian West
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ian West 2015-09-09 06:28:52 UTC
Created attachment 11419 [details]
Patches for ./lib/socket/interfaces.c

The code to collect the interface list does not check that each address is either an IPV4 or and IPV6 address when building the list, it checks for the presence of an ifa_addr and an ifa_netmask field, but this is not always enough.

The iface_comp function only returns defined results for AF_INET or AF_INET6 addresses, for anything else it always returns 0.

This can leave a situation where the resultant list order is undefined resulting in an assertion caused by the macro

#define TYPESAFE_QSORT(base, numel, comparison) \
do { \
  if (numel > 1) { \
    qsort(base, numel, sizeof((base)[0]), (int (*)(const void *, const void *))comparison); \
    assert(comparison(&((base)[0]), &((base)[1])) <= 0); \
  } \
} while (0)

The solution to this is i believe to build the list based on only valid ipv4 or ipv6 address as per the attached patch.