Skip to content

Commit

Permalink
nd6: Update RA link-local addr option length check
Browse files Browse the repository at this point in the history
lwIP might support different hardware address lengths (when using
Ethernet and 6LoWPAN for instance). Match provided lladdr length
from Router Advertisement to the current network interface instead
of comparing against longest that can be stored.
  • Loading branch information
yarrick committed Sep 28, 2023
1 parent 4f78da9 commit 7807f70
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ HISTORY

* [Enter new changes just after this line - do not remove this line]

++ Bugfixes:

2023-09-28: Erik Ekman
* Fix ND6 Router Advertisement parsing when NETIF_MAX_HWADDR_LEN is above 6.

(STABLE-2.2.0):

2018-10-02: Dirk Ziegelmeier
Expand Down
5 changes: 3 additions & 2 deletions src/core/ipv6/nd6.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,12 @@ nd6_input(struct pbuf *p, struct netif *inp)
case ND6_OPTION_TYPE_SOURCE_LLADDR:
{
struct lladdr_option *lladdr_opt;
if (option_len < sizeof(struct lladdr_option)) {
if (option_len < ND6_LLADDR_OPTION_MIN_LENGTH) {
goto lenerr_drop_free_return;
}
lladdr_opt = (struct lladdr_option *)buffer;
if ((default_router_list[i].neighbor_entry != NULL) &&
if ((lladdr_opt->length == inp->hwaddr_len) &&
(default_router_list[i].neighbor_entry != NULL) &&
(default_router_list[i].neighbor_entry->state == ND6_INCOMPLETE)) {
SMEMCPY(default_router_list[i].neighbor_entry->lladdr, lladdr_opt->addr, inp->hwaddr_len);
default_router_list[i].neighbor_entry->state = ND6_REACHABLE;
Expand Down
1 change: 1 addition & 0 deletions src/include/lwip/prot/nd6.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ PACK_STRUCT_END
/** Link-layer address option. */
#define ND6_OPTION_TYPE_SOURCE_LLADDR (0x01)
#define ND6_OPTION_TYPE_TARGET_LLADDR (0x02)
#define ND6_LLADDR_OPTION_MIN_LENGTH (2)
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"
#endif
Expand Down

0 comments on commit 7807f70

Please sign in to comment.