]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: better sanity check on Ipv6 prefix length
authorSamer El-Haj-Mahmoud <samer.el-haj-mahmoud@hpe.com>
Thu, 11 Feb 2016 23:57:59 +0000 (07:57 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Sun, 14 Feb 2016 02:31:20 +0000 (10:31 +0800)
Fix a possible buffer overrun issue that could occur if PrefixLength >
128 . Changed == 128 to >= 128. Also remove check for Byte < 16, which
is no longer possible because of the first change.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud <elhaj@hpe.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
NetworkPkg/Ip6Dxe/Ip6Icmp.c

index db40b81d5ea8f6283b2e9740141b49eda32bc394..f6a9bb406f7f54641049ed09249657b6ae9b131a 100644 (file)
@@ -2,7 +2,8 @@
   The ICMPv6 handle routines to process the ICMPv6 control messages.\r
 \r
   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-\r
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
+  \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -479,7 +480,7 @@ Ip6GetPrefix (
     return ;\r
   }\r
 \r
-  if (PrefixLength == IP6_PREFIX_NUM - 1) {\r
+  if (PrefixLength >= IP6_PREFIX_NUM - 1) {\r
     return ;\r
   }\r
 \r
@@ -487,7 +488,7 @@ Ip6GetPrefix (
   Bit   = (UINT8) (PrefixLength % 8);\r
   Value = Prefix->Addr[Byte];\r
 \r
-  if ((Byte > 0) && (Byte < 16)) {\r
+  if (Byte > 0) {\r
     ZeroMem (Prefix->Addr + Byte, 16 - Byte);\r
   }\r
 \r