make sure p->ifa_addr is not NULL before using it #3322

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@jscipione
Contributor

Description

p->ifa_addr might be a NULL pointer and thus crash the program

From
http://man7.org/linux/man-pages/man3/getifaddrs.3.html

The ifa_addr field points to a structure containing the interface
address. (The sa_family subfield should be consulted to determine
the format of the address structure.) _This field may contain a null
pointer.
_

@jscipione
Contributor

This is needed for Haiku which you guys probably don't care much about, but, is a potential problem on all platforms and doesn't cost much.

@krader1961 krader1961 self-assigned this Aug 23, 2016
@krader1961
Member

I'll merge this since it is obviously correct. However, I'm wondering what ifa_name contains for the interface for which ifa_addr is NULL on your system and the purpose of that interface. Which is to say I'm wondering if there are related incorrect assumptions in the fish code that this particular issue might expose if we better understood the nature of the failure.

@jscipione
Contributor

There are 2 cases where ifa_addr can be NULL on Haiku, one is if an interface's address.sa_family == AF_UNSPEC and the other is if there was an error copying the interface's address (i.e. new throws an exception). The latter is probably not happening so I'm guessing the case we're running into is the former, one or more of the interfaces has an unspecified address family. I'm not sure whether or not there is a bug on our side here, but it is possible.

@floam floam added the bug label Aug 23, 2016
@krader1961
Member

Merged as a872d9c.

@krader1961 krader1961 closed this Aug 24, 2016
@floam floam added this to the next-2.x milestone Aug 24, 2016
@krader1961 krader1961 modified the milestone: fish 2.3.2, next-2.x Sep 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment