public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Jarosch <thomas.jarosch-XXsH3GEs1jrby3iVrkZq2A@public.gmane.org>
To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: getifaddrs: Prevent possible NULL pointer access
Date: Tue, 5 Oct 2010 14:57:23 +0200	[thread overview]
Message-ID: <201010051457.23610.thomas.jarosch@intra2net.com> (raw)

[-- Attachment #1: Type: Text/Plain, Size: 172 bytes --]

Hello,

the example code for getifaddrs() contains a possible NULL pointer access.
Attached is a patch against man-pages 3.22 from Fedora 12.

Best regards,
Thomas Jarosch

[-- Attachment #2: man-pages-getifaddrs-prevent-NULL-access.patch --]
[-- Type: text/x-patch, Size: 561 bytes --]

diff -u -r -p man-pages-3.22/man3/getifaddrs.3 man-pages.prevent_NULL/man3/getifaddrs.3
--- man-pages-3.22/man3/getifaddrs.3	2009-07-25 08:53:32.000000000 +0200
+++ man-pages.prevent_NULL/man3/getifaddrs.3	2010-10-05 14:13:25.536917362 +0200
@@ -245,6 +245,9 @@ main(int argc, char *argv[])
        can free list later */
 
     for (ifa = ifaddr; ifa != NULL; ifa = ifa\->ifa_next) {
+        if (ifa\->ifa_addr == NULL)
+            continue;
+
         family = ifa\->ifa_addr\->sa_family;
 
         /* Display interface name and family (including symbolic

             reply	other threads:[~2010-10-05 12:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05 12:57 Thomas Jarosch [this message]
     [not found] ` <201010051457.23610.thomas.jarosch-XXsH3GEs1jrby3iVrkZq2A@public.gmane.org>
2010-10-06  5:35   ` getifaddrs: Prevent possible NULL pointer access Michael Kerrisk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201010051457.23610.thomas.jarosch@intra2net.com \
    --to=thomas.jarosch-xxsh3ges1jrby3ivrkzq2a@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox