]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Link State memory corruption
authorOlivier Dugeon <olivier.dugeon@orange.com>
Fri, 21 Apr 2023 16:09:28 +0000 (18:09 +0200)
committerOlivier Dugeon <olivier.dugeon@orange.com>
Fri, 21 Apr 2023 16:09:28 +0000 (18:09 +0200)
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>
lib/link_state.c

index 0aba021b1af7f7597f051db7016b6226441fecb0..c06a42b64e66dffda182cba6331954aabd150e5e 100644 (file)
@@ -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);
 }