Bug 11503 - Some interface configurations will core dump all samba utilities assertion in interfaces.c
Summary: Some interface configurations will core dump all samba utilities assertion in...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Other (show other bugs)
Version: 4.2.3
Hardware: All All
: P5 major (vote)
Target Milestone: ---
Assignee: Andrew Bartlett
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-09 06:28 UTC by Ian West
Modified: 2024-04-10 23:37 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.