[PATCH] get_interfaces() return early causes segfault in winbind

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Oct 25 18:31:57 UTC 2018


On Thu, Oct 25, 2018 at 09:18:53AM -0600, David Mulder via samba-technical wrote:
> Regression caused by da68a1b2f417ec82ea4ed3e7a4d867cef8ca8f93.
> 
> If we return early, be sure to point pifaces to the returned ifaces if
> we have 1 return. Otherwise winbind segfaults in load_interfaces() if
> there is only 1 interface, because we say there is 1 interface, but
> ifaces is NULL (load_interfaces() tries to smb_memdup NULL of iface size 1).
> 
> Seen on a machine where dhcp was slow to return, so winbind crashed on
> started due to lo being the only interface available on start.
> 
> Please review and push if ok!

Looks right. A little stylistic comment:

> -	if (total <= 1) {
> +	if (total <= 0) {
> +		return total;
> +	} else if (total == 1) {
> +		*pifaces = ifaces;

Can we just remove the "else"? We do the early return in the first
clause, we don't need an "else".

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de



More information about the samba-technical mailing list