diff options
author | Dmitry Valter <d-valter@yandex-team.ru> | 2022-12-12 11:43:33 +0000 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2022-12-16 17:25:27 +0000 |
commit | 415b6a7c75d003b90d8a7f02563ab41f1b036c21 (patch) | |
tree | 3a4405e674912df40f557c3c2ea95ec9b637c284 /src/vnet/bfd/bfd_udp.c | |
parent | 4117b24acb4241d7f2ef38248bc254f6a4a7b422 (diff) |
bfd: fix bfd udp error enum incompatibility
New BFD UDP errors were no longer compatible with BFD errors. This was causing
out-of-bound reads and ASAN test crashes.
Fix this issue by statically checking if these enums are compatible.
Type: fix
Signed-off-by: Dmitry Valter <d-valter@yandex-team.ru>
Change-Id: I92fddd26270f946bc16ade840c94e5496e2cb88a
Diffstat (limited to 'src/vnet/bfd/bfd_udp.c')
-rw-r--r-- | src/vnet/bfd/bfd_udp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/vnet/bfd/bfd_udp.c b/src/vnet/bfd/bfd_udp.c index 37bb102d2d9..2ba43a309d1 100644 --- a/src/vnet/bfd/bfd_udp.c +++ b/src/vnet/bfd/bfd_udp.c @@ -42,6 +42,14 @@ #include <vnet/bfd/bfd_api.h> #include <vnet/bfd/bfd.api_enum.h> +#define F(sym, str) \ + STATIC_ASSERT ((int) BFD_ERROR_##sym == (int) BFD_UDP_ERROR_##sym, \ + "BFD error enums mismatch"); +foreach_bfd_error (F) +#undef F + STATIC_ASSERT ((int) BFD_N_ERROR <= (int) BFD_UDP_N_ERROR, + "BFD error enum sizes mismatch"); + typedef struct { bfd_main_t *bfd_main; |