mirror of https://github.com/mkerrisk/man-pages
getifaddrs.3: Prevent possible NULL pointer access in example program
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
9d7a9f90c7
commit
ebd05fecfe
|
@ -30,7 +30,7 @@
|
|||
.\" for glibc specificities, provide an example.
|
||||
.\" 2009-01-14 mtk, many edits and changes, rewrote example program.
|
||||
.\"
|
||||
.TH GETIFADDRS 3 2009-01-23 "GNU" "Linux Programmer's Manual"
|
||||
.TH GETIFADDRS 3 2010-10-06 "GNU" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
getifaddrs, freeifaddrs \- get interface addresses
|
||||
.SH SYNOPSIS
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue