[edk2] [Patch 3/3] MdeModulePkg/DxeNetLib: Fix an error in packet length counting.

fanwang2 posted 3 patches 6 years, 11 months ago
[edk2] [Patch 3/3] MdeModulePkg/DxeNetLib: Fix an error in packet length counting.
Posted by fanwang2 6 years, 11 months ago
From: Wang Fan <fan.wang@intel.com>

* In old implementation, the operation len-- assumes AsciiSPrint()
  has counted NULL terminator, and it's not correct. This patch is
  to fix this issue.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
---
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 90f17b7..cbce28f 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -401,22 +401,21 @@ SyslogBuildPacket (
                     Time.Day,
                     Time.Hour,
                     Time.Minute,
                     Time.Second
                     );
-  Len--;
 
   Len += (UINT32) AsciiSPrint (
                     Buf + Len,
                     BufLen - Len,
                     "Tiano %a: %a (Line: %d File: %a)",
                     Module,
                     Message,
                     Line,
                     File
                     );
-  Len--;
+  Len ++;
 
   //
   // OK, patch the IP length/checksum and UDP length fields.
   //
   Len           += sizeof (EFI_UDP_HEADER);
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch 3/3] MdeModulePkg/DxeNetLib: Fix an error in packet length counting.
Posted by Wu, Jiaxin 6 years, 11 months ago
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>


> -----Original Message-----
> From: Wang, Fan
> Sent: Wednesday, January 3, 2018 10:32 AM
> To: edk2-devel@lists.01.org
> Cc: Wang, Fan <fan.wang@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Ye,
> Ting <ting.ye@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [Patch 3/3] MdeModulePkg/DxeNetLib: Fix an error in packet length
> counting.
> 
> From: Wang Fan <fan.wang@intel.com>
> 
> * In old implementation, the operation len-- assumes AsciiSPrint()
>   has counted NULL terminator, and it's not correct. This patch is
>   to fix this issue.
> 
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan <fan.wang@intel.com>
> ---
>  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> index 90f17b7..cbce28f 100644
> --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> @@ -401,22 +401,21 @@ SyslogBuildPacket (
>                      Time.Day,
>                      Time.Hour,
>                      Time.Minute,
>                      Time.Second
>                      );
> -  Len--;
> 
>    Len += (UINT32) AsciiSPrint (
>                      Buf + Len,
>                      BufLen - Len,
>                      "Tiano %a: %a (Line: %d File: %a)",
>                      Module,
>                      Message,
>                      Line,
>                      File
>                      );
> -  Len--;
> +  Len ++;
> 
>    //
>    // OK, patch the IP length/checksum and UDP length fields.
>    //
>    Len           += sizeof (EFI_UDP_HEADER);
> --
> 1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel