net/lwip: fix the coding error
This patch prevent approaching lladdr opt pointer after
it became null pointer
@@ -222,6 +222,8 @@ void nd6_input(struct pbuf *p, struct netif *inp)
while (p->len >= offset + 8) {
lladdr_opt = (struct lladdr_option *)((u8_t *) p->payload + offset);
+ offset += (ND6H_LLADDR_OPT_LEN(lladdr_opt) << 3);
+
if (ND6H_LLADDR_OPT_LEN(lladdr_opt) == 0) {
pbuf_free(p);
ND6_STATS_INC(nd6.lenerr);
@@ -234,8 +236,6 @@ void nd6_input(struct pbuf *p, struct netif *inp)
* only target lladdr option is possible option for NA message */
lladdr_opt = NULL;
}
-
- offset += (ND6H_LLADDR_OPT_LEN(lladdr_opt) << 3);
}
}
@@ -445,6 +445,8 @@ void nd6_input(struct pbuf *p, struct netif *inp)
while (p->len >= offset + 8) {
lladdr_opt = (struct lladdr_option *)((u8_t *) p->payload + offset);
+ offset += (ND6H_LLADDR_OPT_LEN(lladdr_opt) << 3);
+
if (ND6H_LLADDR_OPT_LEN(lladdr_opt) == 0) {
pbuf_free(p);
ND6_STATS_INC(nd6.lenerr);
@@ -457,8 +459,6 @@ void nd6_input(struct pbuf *p, struct netif *inp)
* only source lladdr option is possible option for NS message */
lladdr_opt = NULL;
}
-
- offset += (ND6H_LLADDR_OPT_LEN(lladdr_opt) << 3);
}
}
