public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] [Patch] MdeModulePkg: Add error handling when IP address is Class E
@ 2018-01-02  2:44 fanwang2
  2018-01-02  6:24 ` Wu, Jiaxin
  0 siblings, 1 reply; 2+ messages in thread
From: fanwang2 @ 2018-01-02  2:44 UTC (permalink / raw)
  To: edk2-devel; +Cc: Wang Fan, Jiaxin Wu, Ye Ting, Fu Siyuan

From: Wang Fan <fan.wang@intel.com>

The Dhcp4.TransmitReceive() API should be able to use at any time according
to UEFI spec. While in classless addressing network, the netmask must be
explicitly provided together with the station address.
But if the DHCP instance haven't be configured with a valid netmask, we need
compute it according to the classful addressing rule. In such case, if the
user configures with class E IP address, ASSERT will happen, we need to handle
this case and return error status code.

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

diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
index aad6674..b95aede 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
@@ -1184,12 +1184,14 @@ EfiDhcp4Build (
   Callback by UdpIoCreatePort() when creating UdpIo for this Dhcp4 instance.
 
   @param[in] UdpIo      The UdpIo being created.
   @param[in] Context    Dhcp4 instance.
 
-  @retval EFI_SUCCESS   UdpIo is configured successfully.
-  @retval other         Other error occurs.
+  @retval EFI_SUCCESS              UdpIo is configured successfully.
+  @retval EFI_INVALID_PARAMETER    Class E IP address is not supported or other parameters
+                                   are not valid.
+  @retval other                    Other error occurs.
 **/
 EFI_STATUS
 EFIAPI
 Dhcp4InstanceConfigUdpIo (
   IN UDP_IO       *UdpIo,
@@ -1227,11 +1229,18 @@ Dhcp4InstanceConfigUdpIo (
     // provided together with the station address.
     // If the DHCP instance haven't be configured with a valid netmask, we could only
     // compute it according to the classful addressing rule.
     //
     Class = NetGetIpClass (ClientAddr);
+    //
+    //  Class E IP address is not supported here!
+    //
     ASSERT (Class < IP4_ADDR_CLASSE);
+    if (Class >= IP4_ADDR_CLASSE) {
+      return EFI_INVALID_PARAMETER;
+    }
+    
     SubnetMask = gIp4AllMasks[Class << 3];
   } else {
     SubnetMask = DhcpSb->Netmask;
   }
 
-- 
1.9.5.msysgit.1



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

* Re: [Patch] [Patch] MdeModulePkg: Add error handling when IP address is Class E
  2018-01-02  2:44 [Patch] [Patch] MdeModulePkg: Add error handling when IP address is Class E fanwang2
@ 2018-01-02  6:24 ` Wu, Jiaxin
  0 siblings, 0 replies; 2+ messages in thread
From: Wu, Jiaxin @ 2018-01-02  6:24 UTC (permalink / raw)
  To: Wang, Fan, edk2-devel@lists.01.org; +Cc: Ye, Ting, Fu, Siyuan

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

Please update the copyright before commit the patch.

Thanks,
Jiaxin

> -----Original Message-----
> From: Wang, Fan
> Sent: Tuesday, January 2, 2018 10:45 AM
> To: edk2-devel@lists.01.org
> Cc: Wang, Fan <fan.wang@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Ye,
> Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
> Subject: [Patch] [Patch] MdeModulePkg: Add error handling when IP
> address is Class E
> 
> From: Wang Fan <fan.wang@intel.com>
> 
> The Dhcp4.TransmitReceive() API should be able to use at any time according
> to UEFI spec. While in classless addressing network, the netmask must be
> explicitly provided together with the station address.
> But if the DHCP instance haven't be configured with a valid netmask, we
> need
> compute it according to the classful addressing rule. In such case, if the
> user configures with class E IP address, ASSERT will happen, we need to
> handle
> this case and return error status code.
> 
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan <fan.wang@intel.com>
> ---
>  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 13
> +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> index aad6674..b95aede 100644
> --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> @@ -1184,12 +1184,14 @@ EfiDhcp4Build (
>    Callback by UdpIoCreatePort() when creating UdpIo for this Dhcp4 instance.
> 
>    @param[in] UdpIo      The UdpIo being created.
>    @param[in] Context    Dhcp4 instance.
> 
> -  @retval EFI_SUCCESS   UdpIo is configured successfully.
> -  @retval other         Other error occurs.
> +  @retval EFI_SUCCESS              UdpIo is configured successfully.
> +  @retval EFI_INVALID_PARAMETER    Class E IP address is not supported or
> other parameters
> +                                   are not valid.
> +  @retval other                    Other error occurs.
>  **/
>  EFI_STATUS
>  EFIAPI
>  Dhcp4InstanceConfigUdpIo (
>    IN UDP_IO       *UdpIo,
> @@ -1227,11 +1229,18 @@ Dhcp4InstanceConfigUdpIo (
>      // provided together with the station address.
>      // If the DHCP instance haven't be configured with a valid netmask, we
> could only
>      // compute it according to the classful addressing rule.
>      //
>      Class = NetGetIpClass (ClientAddr);
> +    //
> +    //  Class E IP address is not supported here!
> +    //
>      ASSERT (Class < IP4_ADDR_CLASSE);
> +    if (Class >= IP4_ADDR_CLASSE) {
> +      return EFI_INVALID_PARAMETER;
> +    }
> +
>      SubnetMask = gIp4AllMasks[Class << 3];
>    } else {
>      SubnetMask = DhcpSb->Netmask;
>    }
> 
> --
> 1.9.5.msysgit.1



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

end of thread, other threads:[~2018-01-02  6:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-02  2:44 [Patch] [Patch] MdeModulePkg: Add error handling when IP address is Class E fanwang2
2018-01-02  6:24 ` Wu, Jiaxin

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