public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory leaks
@ 2017-05-21 13:42 Paulo Alcantara
  2017-05-22  2:55 ` Wu, Jiaxin
  2017-05-22 11:52 ` [PATCH v2] " Paulo Alcantara
  0 siblings, 2 replies; 5+ messages in thread
From: Paulo Alcantara @ 2017-05-21 13:42 UTC (permalink / raw)
  To: edk2-devel; +Cc: Paulo Alcantara, Star Zeng, Eric Dong

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
---
 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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory leaks
  2017-05-21 13:42 [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory leaks Paulo Alcantara
@ 2017-05-22  2:55 ` Wu, Jiaxin
  2017-05-22 11:52 ` [PATCH v2] " Paulo Alcantara
  1 sibling, 0 replies; 5+ messages in thread
From: Wu, Jiaxin @ 2017-05-22  2:55 UTC (permalink / raw)
  To: Paulo Alcantara, edk2-devel@lists.01.org
  Cc: Dong, Eric, Zeng, Star, Fu, Siyuan

Hello Paulo,

Thanks your contribution. Only one small comments:
We'd better use "ON_EXIT" instead of "Error" in HttpUrlGetPort() since the PortString should always be freed.

Others is good to me.
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Paulo
> Alcantara
> Sent: Sunday, May 21, 2017 9:42 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com>
> Subject: [edk2] [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory
> leaks
> 
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
> ---
>  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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] MdeModulePkg/DxeHttpLib: Fix potential memory leaks
  2017-05-21 13:42 [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory leaks Paulo Alcantara
  2017-05-22  2:55 ` Wu, Jiaxin
@ 2017-05-22 11:52 ` Paulo Alcantara
  2017-05-23  2:10   ` Wu, Jiaxin
  2017-06-05  7:15   ` Ye, Ting
  1 sibling, 2 replies; 5+ messages in thread
From: Paulo Alcantara @ 2017-05-22 11:52 UTC (permalink / raw)
  To: edk2-devel; +Cc: Paulo Alcantara, Star Zeng, Eric Dong

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
---
 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..2929238 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 ON_EXIT;
   }
 
   PortString[ResultLength] = '\0';
 
   while (Index < ResultLength) {
     if (!NET_IS_DIGIT (PortString[Index])) {
-      return EFI_INVALID_PARAMETER;
+      Status = EFI_INVALID_PARAMETER;
+      goto ON_EXIT;
     }
     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 ON_EXIT;
   }
 
   *Port = (UINT16) Data;
+
+ON_EXIT:
+  FreePool (PortString);
   return Status;
 }
 
@@ -795,6 +803,7 @@ HttpUrlGetPath (
              &ResultLength
              );
   if (EFI_ERROR (Status)) {
+    FreePool (PathStr);
     return Status;
   }
 
-- 
2.9.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] MdeModulePkg/DxeHttpLib: Fix potential memory leaks
  2017-05-22 11:52 ` [PATCH v2] " Paulo Alcantara
@ 2017-05-23  2:10   ` Wu, Jiaxin
  2017-06-05  7:15   ` Ye, Ting
  1 sibling, 0 replies; 5+ messages in thread
From: Wu, Jiaxin @ 2017-05-23  2:10 UTC (permalink / raw)
  To: Paulo Alcantara, edk2-devel@lists.01.org; +Cc: Dong, Eric, Zeng, Star

Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Paulo
> Alcantara
> Sent: Monday, May 22, 2017 7:52 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com>
> Subject: [edk2] [PATCH v2] MdeModulePkg/DxeHttpLib: Fix potential memory
> leaks
> 
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
> ---
>  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..2929238 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 ON_EXIT;
>    }
> 
>    PortString[ResultLength] = '\0';
> 
>    while (Index < ResultLength) {
>      if (!NET_IS_DIGIT (PortString[Index])) {
> -      return EFI_INVALID_PARAMETER;
> +      Status = EFI_INVALID_PARAMETER;
> +      goto ON_EXIT;
>      }
>      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 ON_EXIT;
>    }
> 
>    *Port = (UINT16) Data;
> +
> +ON_EXIT:
> +  FreePool (PortString);
>    return Status;
>  }
> 
> @@ -795,6 +803,7 @@ HttpUrlGetPath (
>               &ResultLength
>               );
>    if (EFI_ERROR (Status)) {
> +    FreePool (PathStr);
>      return Status;
>    }
> 
> --
> 2.9.4
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] MdeModulePkg/DxeHttpLib: Fix potential memory leaks
  2017-05-22 11:52 ` [PATCH v2] " Paulo Alcantara
  2017-05-23  2:10   ` Wu, Jiaxin
@ 2017-06-05  7:15   ` Ye, Ting
  1 sibling, 0 replies; 5+ messages in thread
From: Ye, Ting @ 2017-06-05  7:15 UTC (permalink / raw)
  To: Wu, Jiaxin, Paulo Alcantara, edk2-devel@lists.01.org
  Cc: Dong, Eric, Zeng, Star

Reviewed-by: Ye Ting <ting.ye@intel.com> 

-----Original Message-----
From: Wu, Jiaxin 
Sent: Tuesday, May 23, 2017 10:11 AM
To: Paulo Alcantara <pcacjr@gmail.com>; edk2-devel@lists.01.org
Cc: Dong, Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: RE: [edk2] [PATCH v2] MdeModulePkg/DxeHttpLib: Fix potential memory leaks

Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of 
> Paulo Alcantara
> Sent: Monday, May 22, 2017 7:52 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com>
> Subject: [edk2] [PATCH v2] MdeModulePkg/DxeHttpLib: Fix potential 
> memory leaks
> 
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
> ---
>  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..2929238 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 ON_EXIT;
>    }
> 
>    PortString[ResultLength] = '\0';
> 
>    while (Index < ResultLength) {
>      if (!NET_IS_DIGIT (PortString[Index])) {
> -      return EFI_INVALID_PARAMETER;
> +      Status = EFI_INVALID_PARAMETER;
> +      goto ON_EXIT;
>      }
>      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 ON_EXIT;
>    }
> 
>    *Port = (UINT16) Data;
> +
> +ON_EXIT:
> +  FreePool (PortString);
>    return Status;
>  }
> 
> @@ -795,6 +803,7 @@ HttpUrlGetPath (
>               &ResultLength
>               );
>    if (EFI_ERROR (Status)) {
> +    FreePool (PathStr);
>      return Status;
>    }
> 
> --
> 2.9.4
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-05  7:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-21 13:42 [PATCH] MdeModulePkg/DxeHttpLib: Fix potential memory leaks Paulo Alcantara
2017-05-22  2:55 ` Wu, Jiaxin
2017-05-22 11:52 ` [PATCH v2] " Paulo Alcantara
2017-05-23  2:10   ` Wu, Jiaxin
2017-06-05  7:15   ` Ye, Ting

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox