From cd44428d6230880b0f1c1a34886144889ca4ba79 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 24 Jan 2022 07:02:37 -0500 Subject: [PATCH] bgpd: Prevent use after variable goes out of scope `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 --- bgpd/bgp_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index fa83a457bf..f353abead0 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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"); -- 2.39.5