summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/Ip6Dxe
diff options
context:
space:
mode:
authorsfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>2011-10-08 02:55:30 +0000
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>2011-10-08 02:55:30 +0000
commit02a758cb0b5bc8775d95e0a52acc483f850124a1 (patch)
tree97021cedc2e4bf82766ce9a5f74c4beaf345833d /NetworkPkg/Ip6Dxe
parent4bc6ad3935d7b57e5eacda5e6e70b32d786d43dd (diff)
downloadedk2-02a758cb0b5bc8775d95e0a52acc483f850124a1.tar.gz
edk2-02a758cb0b5bc8775d95e0a52acc483f850124a1.tar.bz2
edk2-02a758cb0b5bc8775d95e0a52acc483f850124a1.zip
Add pointer check for NULL before dereference it.
Signed-off-by: sfu5 Reviewed-by: xdu2 Reviewed-by: ydong10 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12514 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'NetworkPkg/Ip6Dxe')
-rw-r--r--NetworkPkg/Ip6Dxe/Ip6Nd.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.c b/NetworkPkg/Ip6Dxe/Ip6Nd.c
index 47ef74be52..4bcf1a6d44 100644
--- a/NetworkPkg/Ip6Dxe/Ip6Nd.c
+++ b/NetworkPkg/Ip6Dxe/Ip6Nd.c
@@ -1497,13 +1497,16 @@ Ip6ProcessNeighborSolicit (
goto Exit;
} else {
OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH);
- Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
+ if (OptionLen != 0) {
+ Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
+ ASSERT (Option != NULL);
- //
- // All included options should have a length that is greater than zero.
- //
- if (!Ip6IsNDOptionValid (Option, OptionLen)) {
- goto Exit;
+ //
+ // All included options should have a length that is greater than zero.
+ //
+ if (!Ip6IsNDOptionValid (Option, OptionLen)) {
+ goto Exit;
+ }
}
}
@@ -1733,13 +1736,16 @@ Ip6ProcessNeighborAdvertise (
goto Exit;
} else {
OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH);
- Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
+ if (OptionLen != 0) {
+ Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
+ ASSERT (Option != NULL);
- //
- // All included options should have a length that is greater than zero.
- //
- if (!Ip6IsNDOptionValid (Option, OptionLen)) {
- goto Exit;
+ //
+ // All included options should have a length that is greater than zero.
+ //
+ if (!Ip6IsNDOptionValid (Option, OptionLen)) {
+ goto Exit;
+ }
}
}
@@ -1982,10 +1988,13 @@ Ip6ProcessRouterAdvertise (
// All included options have a length that is greater than zero.
//
OptionLen = (UINT16) (Head->PayloadLength - IP6_RA_LENGTH);
- Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL);
+ if (OptionLen != 0) {
+ Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL);
+ ASSERT (Option != NULL);
- if (!Ip6IsNDOptionValid (Option, OptionLen)) {
- goto Exit;
+ if (!Ip6IsNDOptionValid (Option, OptionLen)) {
+ goto Exit;
+ }
}
//
@@ -2428,10 +2437,13 @@ Ip6ProcessRedirect (
// All included options have a length that is greater than zero.
//
OptionLen = (UINT16) (Head->PayloadLength - IP6_REDITECT_LENGTH);
- Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL);
+ if (OptionLen != 0) {
+ Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL);
+ ASSERT (Option != NULL);
- if (!Ip6IsNDOptionValid (Option, OptionLen)) {
- goto Exit;
+ if (!Ip6IsNDOptionValid (Option, OptionLen)) {
+ goto Exit;
+ }
}
Target = (EFI_IPv6_ADDRESS *) (Icmp + 1);