Skip to contentSkip to conversation

getifaddrs: Prevent possible NULL pointer access

PATCH Thomas Jarosch 2 participants 2 messages Oct 5, 2010 – Oct 6, 2010 1 message not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

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

man3/getifaddrs.3 +3 -0
diff -u -r -p man-pages-3.22/man3/getifaddrs.3 man-pages.prevent_NULL/man3/getifaddrs.3
@@ -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
#2 lore raw
In reply to a message not in the archive
Quoted 4 lines · Thomas Jarosch

Hello,

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

Thanks Thomas. Applied for man-pages 3.29.

Cheers,

Michael

Signature · 7 lines
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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html