This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] [BZ #21812] getifaddrs() Don't return ifa entries with NULL names
- From: Daniel Alvarez <dalvarez at redhat dot com>
- To: libc-alpha at sourceware dot org
- Cc: Daniel Alvarez <dalvarez at redhat dot com>
- Date: Mon, 24 Jul 2017 22:56:18 +0200
- Subject: [PATCH] [BZ #21812] getifaddrs() Don't return ifa entries with NULL names
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dalvarez at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A6E4E883C0
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A6E4E883C0
Due to bug 21812, a lookup operation in map_newlink() turns out
into an insert because of holes in the interface part of the map.
This leads to incorrectly set the name of the interface to NULL when
the interface is not present for the address being processed (most
likely because the interface was added between the RTM_GETLINK and
RTM_GETADDR calls to the kernel).
This patch checks this condition and retries the whole operation.
Hopes are that next time the interface corresponding to the address
entry is present in the list and correct name is returned.
Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
---
sysdeps/unix/sysv/linux/ifaddrs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c
index 3bc9902..62421e8 100644
--- a/sysdeps/unix/sysv/linux/ifaddrs.c
+++ b/sysdeps/unix/sysv/linux/ifaddrs.c
@@ -740,7 +740,7 @@ getifaddrs_internal (struct ifaddrs **ifap)
{
int idx = map_newlink (ifam->ifa_index - 1, ifas,
map_newlink_data, newlink);
- if (__glibc_unlikely (idx == -1))
+ if (__glibc_unlikely (idx == -1) || ifas[idx].ifa.ifa_name == NULL)
goto try_again;
ifas[ifa_index].ifa.ifa_name = ifas[idx].ifa.ifa_name;
}
--
2.9.3