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

* Re: getifaddrs()
       [not found] ` <4FF60812.70408-qE3U7d0pukyEhLc4KmoMIOTv7YV0F9Eg@public.gmane.org>
@ 2012-07-06 19:29   ` Simon Paillard
       [not found]     ` <20120706192945.GA15283-8MNqHwMchPhGJ/Ie3qa20WD2FQJk+8+b@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Paillard @ 2012-07-06 19:29 UTC (permalink / raw)
  To: Adrian Dabrowski
  Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w,
	linux-man-u79uwXL29TY76Z2rM5mHXA

Hi,

On Thu, Jul 05, 2012 at 11:33:06PM +0200, Adrian Dabrowski wrote:
> Version: manpages-dev 3.27-1ubuntu2

You should upgrade your manpages-dev version:
http://packages.ubuntu.com/search?keywords=manpages-dev 
 
> 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?))

Thanks for reporting the issue, don't hesitate to report similar reports *that
still apply in current version*.
 
> ORIGINAL:
>            for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
>                family = ifa->ifa_addr->sa_family;

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

           for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
               if (ifa->ifa_addr == NULL)
                   continue;

               family = ifa->ifa_addr->sa_family; 

It has been fixed by
http://git.kernel.org/?p=docs/man-pages/man-pages.git;a=commitdiff;h=ebd05fecfe

> 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 regards.

-- 
Simon Paillard
--
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

* Re: getifaddrs()
       [not found]     ` <20120706192945.GA15283-8MNqHwMchPhGJ/Ie3qa20WD2FQJk+8+b@public.gmane.org>
@ 2012-07-07  6:20       ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Kerrisk (man-pages) @ 2012-07-07  6:20 UTC (permalink / raw)
  To: Simon Paillard; +Cc: Adrian Dabrowski, linux-man-u79uwXL29TY76Z2rM5mHXA

On Fri, Jul 6, 2012 at 9:29 PM, Simon Paillard
<simon.paillard-RGJHTEmuthQGuQl/6FzYuenJ6Cvpl5oe@public.gmane.org> wrote:
> Hi,
>
> On Thu, Jul 05, 2012 at 11:33:06PM +0200, Adrian Dabrowski wrote:
>> Version: manpages-dev 3.27-1ubuntu2
>
> You should upgrade your manpages-dev version:
> http://packages.ubuntu.com/search?keywords=manpages-dev
>
>> 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?))
>
> Thanks for reporting the issue, don't hesitate to report similar reports *that
> still apply in current version*.
>
>> ORIGINAL:
>>            for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
>>                family = ifa->ifa_addr->sa_family;
>
> http://man7.org/linux/man-pages/man3/getifaddrs.3.html
>
>            for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
>                if (ifa->ifa_addr == NULL)
>                    continue;
>
>                family = ifa->ifa_addr->sa_family;
>
> It has been fixed by
> http://git.kernel.org/?p=docs/man-pages/man-pages.git;a=commitdiff;h=ebd05fecfe
>
>> 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;
>>

Adrian, thanks for the note.

Simon, thanks for the review. From the above, I think nothing needs to
be applied, but:

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

I applied the following patch for 3.42:

[[
--- a/man3/getifaddrs.3
+++ b/man3/getifaddrs.3
@@ -98,20 +98,22 @@ for a list of these flags).
 The
 .I ifa_addr
 field points to a structure containing the interface address.
 (The
 .I sa_family
 subfield should be consulted to determine the format of the
 address structure.)
+This field may contain a NULL pointer.
 .PP
 The
 .I ifa_netmask
 field points to a structure containing the netmask associated with
 .IR ifa_addr ,
 if applicable for the address family.
+This field may contain a NULL pointer.
 .PP
 Depending on whether the bit
 .B IFF_BROADCAST
 or
 .B IFF_POINTOPOINT
 is set in
 .I ifa_flags
]]

Thanks,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/
--
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