From: Claudio Jeker Subject: bgpctl: fix smaller issues To: tech@openbsd.org Date: Tue, 4 Nov 2025 16:24:33 +0100 Coverity found those: - Initalize neighbor since we don't touch all members when setting it up. - In fmt_flags() increase the flagstr to be able to hold all flags even though some flags are mutually exclusive but lets play it safe. - Error out if multiple mrt files are provided. It makes no sense to set more than one file. Fixes for CID 492333, 492337 and 492338 -- :wq Claudio Index: bgpctl.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v diff -u -p -r1.318 bgpctl.c --- bgpctl.c 4 Nov 2025 10:59:17 -0000 1.318 +++ bgpctl.c 4 Nov 2025 15:11:31 -0000 @@ -86,7 +86,7 @@ main(int argc, char *argv[]) struct imsg imsg; struct network_config net; struct parse_result *res; - struct ctl_neighbor neighbor; + struct ctl_neighbor neighbor = { 0 }; struct ctl_show_rib_request ribreq; struct flowspec *f; char *sockname; @@ -747,7 +747,7 @@ const char * fmt_flags(uint32_t flags, int sum) { static char buf[80]; - char flagstr[5]; + char flagstr[12]; char *p = flagstr; if (sum) { Index: parser.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpctl/parser.c,v diff -u -p -r1.138 parser.c --- parser.c 10 Mar 2025 14:08:25 -0000 1.138 +++ parser.c 4 Nov 2025 15:15:55 -0000 @@ -489,6 +489,7 @@ parse(int argc, char *argv[]) memset(&res, 0, sizeof(res)); res.rtableid = getrtable(); + res.mrtfd = -1; TAILQ_INIT(&res.set); while (argc >= 0) { @@ -801,6 +802,8 @@ match_token(int argc, char *argv[], cons break; case FILENAME: if (word != NULL && wordlen > 0) { + if (res.mrtfd != -1) + errx(1, "mrt file already set"); if ((res.mrtfd = open(word, O_RDONLY)) == -1) { /* * ignore error if path has no / and