NetworkPkg/Ip6Dxe: Fix ASSERT logic in Ip6ProcessRouterAdvertise()

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2655

This patch fixes reversed logic of recently added ASSERTs which should
ensure that Ip6IsNDOptionValid() implementation properly reacts to invalid
packets.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Fixes: 9c20342eed
This commit is contained in:
Maciej Rabeda 2020-04-01 11:43:55 +02:00 committed by mergify[bot]
parent e210fc130e
commit 4deef2d865
1 changed files with 3 additions and 3 deletions

View File

@ -2111,7 +2111,7 @@ Ip6ProcessRouterAdvertise (
// Option size validity ensured by Ip6IsNDOptionValid(). // Option size validity ensured by Ip6IsNDOptionValid().
// //
ASSERT (LinkLayerOption.Length != 0); ASSERT (LinkLayerOption.Length != 0);
ASSERT (Offset + (UINT32) LinkLayerOption.Length * 8 >= (UINT32) Head->PayloadLength); ASSERT (Offset + (UINT32) LinkLayerOption.Length * 8 <= (UINT32) Head->PayloadLength);
ZeroMem (&LinkLayerAddress, sizeof (EFI_MAC_ADDRESS)); ZeroMem (&LinkLayerAddress, sizeof (EFI_MAC_ADDRESS));
CopyMem (&LinkLayerAddress, LinkLayerOption.EtherAddr, 6); CopyMem (&LinkLayerAddress, LinkLayerOption.EtherAddr, 6);
@ -2164,7 +2164,7 @@ Ip6ProcessRouterAdvertise (
// Option size validity ensured by Ip6IsNDOptionValid(). // Option size validity ensured by Ip6IsNDOptionValid().
// //
ASSERT (PrefixOption.Length == 4); ASSERT (PrefixOption.Length == 4);
ASSERT (Offset + (UINT32) PrefixOption.Length * 8 >= (UINT32) Head->PayloadLength); ASSERT (Offset + (UINT32) PrefixOption.Length * 8 <= (UINT32) Head->PayloadLength);
PrefixOption.ValidLifetime = NTOHL (PrefixOption.ValidLifetime); PrefixOption.ValidLifetime = NTOHL (PrefixOption.ValidLifetime);
PrefixOption.PreferredLifetime = NTOHL (PrefixOption.PreferredLifetime); PrefixOption.PreferredLifetime = NTOHL (PrefixOption.PreferredLifetime);
@ -2334,7 +2334,7 @@ Ip6ProcessRouterAdvertise (
// Option size validity ensured by Ip6IsNDOptionValid(). // Option size validity ensured by Ip6IsNDOptionValid().
// //
ASSERT (MTUOption.Length == 1); ASSERT (MTUOption.Length == 1);
ASSERT (Offset + (UINT32) MTUOption.Length * 8 >= (UINT32) Head->PayloadLength); ASSERT (Offset + (UINT32) MTUOption.Length * 8 <= (UINT32) Head->PayloadLength);
// //
// Use IPv6 minimum link MTU 1280 bytes as the maximum packet size in order // Use IPv6 minimum link MTU 1280 bytes as the maximum packet size in order