From nobody Thu May 2 13:06:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495374161317564.237692427858; Sun, 21 May 2017 06:42:41 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A3FAC21A16EFC; Sun, 21 May 2017 06:42:38 -0700 (PDT) Received: from mail-qk0-x241.google.com (mail-qk0-x241.google.com [IPv6:2607:f8b0:400d:c09::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F2D821A16EE9 for ; Sun, 21 May 2017 06:42:36 -0700 (PDT) Received: by mail-qk0-x241.google.com with SMTP id y128so15850037qka.3 for ; Sun, 21 May 2017 06:42:36 -0700 (PDT) Received: from thor.domain.name ([2804:7f4:c380:3a94::3]) by smtp.gmail.com with ESMTPSA id j8sm7682596qtb.38.2017.05.21.06.42.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 May 2017 06:42:34 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+kK2/d5kNfxTwvlqeFIx90CzLatzNp6BzQc0N1CRNdE=; b=SzSOG5K82XcCObrfKM9W3KaHHjLAvO/WH4Q4LlU2SpNW70fT04k3qka18rCIJlIy3t Tmf64loFECw9wiwDtJMbnOl+wweCHCm097OFv8L3ndSJh7zGSRlMH0XkfKjpVMuAopDc Daw19/iloBY8p2rzzgsZX1O7uRZlVAt9FqEQgFM+8pLLnK5LLLQiat7+wJixoPmgf/LH BpOduZ8Iyy63GbLDh0QZSpBGpFZ/Bk7fafDSK4Lwobtall7dQX7NRbQjGI9uhPOpaVys RHkBr5+ENyTCNSlNoh/G+r18MFyWlP36AsoEyRdsRhGHiTPi40uSl34Fd0o7zRexvRoX qNPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+kK2/d5kNfxTwvlqeFIx90CzLatzNp6BzQc0N1CRNdE=; b=EpS6PDWmRyYxc703iK8FpQE49VLqSqN20JaSplo4e9U3mFmE2N0oaHSbldhx35fkzV JbOCKHj0Cr/hDIpa52QAJd6gmk54s3lbpce8gsiwmhSsy9bvkllA6ZAHfdwtzBYQtJ6J ALGjpCj6Jf2niAhLT0g0hedkDFb53w/Oy6aVathRZsFSelHdup/COkFU+UzgLfo9QBsp IF/g0Lhk1Pw7i+ebdNsdreLfxt8bPcfdJoLyM7Ic6dHctrbZh5ow1m7DmNA3fGfQ1yVX +ewM53c13qvwkCrCFHj7BCI4/qGngZJ+4+qpbyyY9QfA8w/1AtuRFYyc6M6QDpnBnqY3 PqYg== X-Gm-Message-State: AODbwcAOLVdtHtog8ZTg3BFHVkrHW07V7Ci7mEJzSpdCXrACpJxtBZoC CmaRUc5Pubndpg== X-Received: by 10.55.198.197 with SMTP id s66mr18706236qkl.179.1495374155493; Sun, 21 May 2017 06:42:35 -0700 (PDT) From: Paulo Alcantara To: edk2-devel@lists.01.org Date: Sun, 21 May 2017 10:42:17 -0300 Message-Id: <20170521134217.6667-1-pcacjr@gmail.com> X-Mailer: git-send-email 2.9.4 Subject: [edk2] [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory leaks X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Paulo Alcantara Reviewed-by: Wu Jiaxin --- MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c b/MdeModulePkg/Li= brary/DxeHttpLib/DxeHttpLib.c index 8421caa..0523227 100644 --- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c +++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c @@ -523,6 +523,7 @@ HttpUrlGetHostName ( &ResultLength ); if (EFI_ERROR (Status)) { + FreePool (Name); return Status; } =20 @@ -582,6 +583,7 @@ HttpUrlGetIp4 ( &ResultLength ); if (EFI_ERROR (Status)) { + FreePool (Ip4String); return Status; } =20 @@ -657,6 +659,7 @@ HttpUrlGetIp6 ( &ResultLength ); if (EFI_ERROR (Status)) { + FreePool (Ip6String); return Status; } =20 @@ -722,14 +725,15 @@ HttpUrlGetPort ( &ResultLength ); if (EFI_ERROR (Status)) { - return Status; + goto Error; } =20 PortString[ResultLength] =3D '\0'; =20 while (Index < ResultLength) { if (!NET_IS_DIGIT (PortString[Index])) { - return EFI_INVALID_PARAMETER; + Status =3D EFI_INVALID_PARAMETER; + goto Error; } Index ++; } @@ -737,10 +741,14 @@ HttpUrlGetPort ( Status =3D AsciiStrDecimalToUintnS (Url + Parser->FieldData[HTTP_URI_FI= ELD_PORT].Offset, (CHAR8 **) NULL, &Data); =20 if (Data > HTTP_URI_PORT_MAX_NUM) { - return EFI_INVALID_PARAMETER; + Status =3D EFI_INVALID_PARAMETER; + goto Error; } =20 *Port =3D (UINT16) Data; + +Error: + FreePool (PortString); return Status; } =20 @@ -795,6 +803,7 @@ HttpUrlGetPath ( &ResultLength ); if (EFI_ERROR (Status)) { + FreePool (PathStr); return Status; } =20 --=20 2.9.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel