summaryrefslogtreecommitdiff
path: root/lib/link_state.c
diff options
context:
space:
mode:
authorOlivier Dugeon <olivier.dugeon@orange.com>2023-04-21 18:09:28 +0200
committerOlivier Dugeon <olivier.dugeon@orange.com>2023-04-21 18:09:28 +0200
commit871b46e7eb86009f1bea3cf397a8d2c38ceacd40 (patch)
treeb701ce6347a454b029cc08d42a53e3c5a1a2a09a /lib/link_state.c
parent0633fb7856e75f5631d25386eb240b49d1f5cb0d (diff)
lib: Link State memory corruption
In function ls_find_subnet(), prefix argument is directly copied into subnet.key structure to find corresponding subnet in RB Tree. This could leadr to a memory corruption. Function prefix_copy() must be used instead. This patch replaces the direct prefix copy by a call to prefix_copy() function to avoid this memory issue. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Diffstat (limited to 'lib/link_state.c')
-rw-r--r--lib/link_state.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/link_state.c b/lib/link_state.c
index 0aba021b1a..c06a42b64e 100644
--- a/lib/link_state.c
+++ b/lib/link_state.c
@@ -947,7 +947,10 @@ struct ls_subnet *ls_find_subnet(struct ls_ted *ted,
{
struct ls_subnet subnet = {};
- subnet.key = *prefix;
+ if (!prefix)
+ return NULL;
+
+ prefix_copy(&subnet.key, prefix);
return subnets_find(&ted->subnets, &subnet);
}