From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) 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) 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) From: Paulo Alcantara To: edk2-devel@lists.01.org Cc: Paulo Alcantara , Star Zeng , Eric Dong 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: [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: , X-List-Received-Date: Sun, 21 May 2017 13:42:36 -0000 Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Paulo Alcantara --- MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c b/MdeModulePkg/Library/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; } @@ -582,6 +583,7 @@ HttpUrlGetIp4 ( &ResultLength ); if (EFI_ERROR (Status)) { + FreePool (Ip4String); return Status; } @@ -657,6 +659,7 @@ HttpUrlGetIp6 ( &ResultLength ); if (EFI_ERROR (Status)) { + FreePool (Ip6String); return Status; } @@ -722,14 +725,15 @@ HttpUrlGetPort ( &ResultLength ); if (EFI_ERROR (Status)) { - return Status; + goto Error; } PortString[ResultLength] = '\0'; while (Index < ResultLength) { if (!NET_IS_DIGIT (PortString[Index])) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Error; } Index ++; } @@ -737,10 +741,14 @@ HttpUrlGetPort ( Status = AsciiStrDecimalToUintnS (Url + Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data); if (Data > HTTP_URI_PORT_MAX_NUM) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Error; } *Port = (UINT16) Data; + +Error: + FreePool (PortString); return Status; } @@ -795,6 +803,7 @@ HttpUrlGetPath ( &ResultLength ); if (EFI_ERROR (Status)) { + FreePool (PathStr); return Status; } -- 2.9.4