public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* getifaddrs()
@ 2012-07-05 21:33 Adrian Dabrowski
       [not found] ` <4FF60812.70408-qE3U7d0pukyEhLc4KmoMIOTv7YV0F9Eg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Dabrowski @ 2012-07-05 21:33 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w,
	linux-man-u79uwXL29TY76Z2rM5mHXA

Version: manpages-dev 3.27-1ubuntu2


The example program source produces a Seg-Fault, when a device does not 
have an ifa->ifa_addr. (e.g. openvpn-tunnels, probably others (dialup?))


ORIGINAL:
            for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
                family = ifa->ifa_addr->sa_family;


POSSIBLE FIX:
            for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
		if (ifa->ifa_addr != NULL)
                		family = ifa->ifa_addr->sa_family;
		else
			family = -1;


Also it is not documented, that  struct sockaddr *ifa_addr  might be NULL.


best wishes and keep up the good work,
Adrian Dabrowski
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-07  6:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-05 21:33 getifaddrs() Adrian Dabrowski
     [not found] ` <4FF60812.70408-qE3U7d0pukyEhLc4KmoMIOTv7YV0F9Eg@public.gmane.org>
2012-07-06 19:29   ` getifaddrs() Simon Paillard
     [not found]     ` <20120706192945.GA15283-8MNqHwMchPhGJ/Ie3qa20WD2FQJk+8+b@public.gmane.org>
2012-07-07  6:20       ` getifaddrs() Michael Kerrisk (man-pages)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox