From patchwork Mon Jul 24 20:56:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Alvarez X-Patchwork-Id: 21746 Received: (qmail 113372 invoked by alias); 24 Jul 2017 20:56:26 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 112273 invoked by uid 89); 24 Jul 2017 20:56:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1306 X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A6E4E883C0 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@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A6E4E883C0 From: Daniel Alvarez To: libc-alpha@sourceware.org Cc: Daniel Alvarez Subject: [PATCH] [BZ #21812] getifaddrs() Don't return ifa entries with NULL names Date: Mon, 24 Jul 2017 22:56:18 +0200 Message-Id: <20170724205618.21515-1-dalvarez@redhat.com> 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 --- 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; }