]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Prevent use after variable goes out of scope
authorDonald Sharp <sharpd@nvidia.com>
Mon, 24 Jan 2022 12:02:37 +0000 (07:02 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 4 Feb 2022 15:29:38 +0000 (10:29 -0500)
`struct prefix p` was declared inside an if statement
where we assign the address of to a pointer that is
then passed to a sub function.  This will eventually
leave us in a bad state.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_route.c

index fa83a457bf8e38d5f0ba916f9c3ee93f30d1036e..f353abead07a893dd381cbe64aded3fd23d211b6 100644 (file)
@@ -12249,6 +12249,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
        bool first = true;
        uint16_t show_flags = 0;
        enum rpki_states rpki_target_state = RPKI_NOT_BEING_USED;
+       struct prefix p;
 
        if (uj) {
                argc--;
@@ -12401,7 +12402,6 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
        if (argv_find(argv, argc, "A.B.C.D/M", &idx)
            || argv_find(argv, argc, "X:X::X:X/M", &idx)) {
                const char *prefix_str = argv[idx]->arg;
-               struct prefix p;
 
                if (!str2prefix(prefix_str, &p)) {
                        vty_out(vty, "%% Malformed Prefix\n");