From patchwork Mon Jan 20 17:00:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1226072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108843-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=O7HtWsP5; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eA0N36Eh; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 481dH361tdz9sR1 for ; Tue, 21 Jan 2020 04:01:19 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=Yn2 62c8r5XdVxPgx+QM8fV8kz8XW/BiwlFjt9fcGJy+nF1IZLizU4UXGcFSYbStQkBF NiJ9ryOvP2ZZQ+1Ldqfy3UqmCWSweJuSVNnyi+o4JhO3f47cH3xXPy1LjiFMlDh8 Wo8E1rzOfG6v8ZGLJ3X1q+kSbKA+hi+SMWun6lQE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=8lAuj0zrx 3Sc56SvOGpk6AO/Pdw=; b=O7HtWsP5Z4Z0vbyVYOl26dV1y/6PvP5lWdjeYEDUI 6JGnTvc8e4+GzKBTT0L+PTqPEYmwNiss5bq2MtIPtCSklrRynI+kXsaX+TWgsGbw xLVmVyZ+PyIznTl0ijM61NeN7BNuk5BZGC7oXB2DeB4r5jfYgVJJmquz7JCet7+j Ig= Received: (qmail 23232 invoked by alias); 20 Jan 2020 17:01:13 -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 23211 invoked by uid 89); 20 Jan 2020 17:01:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579539660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qIif2bP7sKBg82WZ82uO2InVHzG0Oytq+Wdyp3Eq2LQ=; b=eA0N36EhaHqDmKINhaCBWWOJhPwRwf7e3rAO3+iwhJ7XMzETHeSdJSGuqm7FAHYTU/9Sxq X61oPktHloWs9czhrE572fAhW0Z9KGisacMAqY0V5qIGi0ZZorEnPMcvyvK+wUnIzBbgJm 3V3G/XssTgbUocaf9e88otPBm8hUZ/w= From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] getaddrinfo: Fix resource leak after strdup failure in gethosts [BZ #25425] Date: Mon, 20 Jan 2020 18:00:56 +0100 Message-ID: <87eevuukon.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Filip Ochnik spotted that one of the error jumps in gethosts fails to call __resolv_context_put to release the resolver context. Fixes commit 352f4ff9a268b81ef5d4b2413f582565806e4790 ("resolv: Introduce struct resolv_context [BZ #21668]") and commit 964263bb8d650f1681665c55704fb01a8e725621 ("getaddrinfo: Release resolver context on error in gethosts [BZ #21885]"). ----- sysdeps/posix/getaddrinfo.c | 1 + 1 file changed, 1 insertion(+) Reviewed-by: Siddhesh Poyarekar diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index f813d85aa3..538691a598 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -288,6 +288,7 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, canonbuf = __strdup (localcanon); \ if (canonbuf == NULL) \ { \ + __resolv_context_put (res_ctx); \ result = -EAI_SYSTEM; \ goto free_and_return; \ } \