summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2023-04-28 13:23:53 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2023-04-28 13:23:53 +0000
commit46f0813683f74ee74e7083e8f9252a0ac4b36cf5 (patch)
tree4669c4d386788797e528ff89a2263a4d395844e5 /usr.sbin/bgpd
parentf53f85fa202e8dba9c2ee5346e4081ec453ab5ee (diff)
Add explicit default labels in switch() statements with error handling.
Right now these are not reachable. Should also clear some gcc warnings. OK tb@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/parse.y5
-rw-r--r--usr.sbin/bgpd/printconf.c17
2 files changed, 14 insertions, 8 deletions
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 3ca06b539b1..b6a182040c1 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.453 2023/04/26 18:14:28 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.454 2023/04/28 13:23:52 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -5683,6 +5683,9 @@ push_prefix(struct bgpd_addr *addr, uint8_t len)
complen = PREFIX_SIZE(len) + 1;
data = &addr->v6;
break;
+ default:
+ yyerror("unsupported address family for flowspec address");
+ return -1;
}
comp = malloc(complen);
if (comp == NULL) {
diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c
index 75fa425e73d..32be9d82042 100644
--- a/usr.sbin/bgpd/printconf.c
+++ b/usr.sbin/bgpd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.166 2023/04/21 10:48:33 claudio Exp $ */
+/* $OpenBSD: printconf.c,v 1.167 2023/04/28 13:23:52 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -542,12 +542,6 @@ print_flowspec_flags(struct flowspec *f, int type, int is_v6)
const char *fmt, *flags;
int complen, off = 0;
- if (flowspec_get_component(f->data, f->len, type, is_v6,
- &comp, &complen) != 1)
- return;
-
- printf("%s ", flowspec_fmt_label(type));
-
switch (type) {
case FLOWSPEC_TYPE_TCP_FLAGS:
flags = FLOWSPEC_TCP_FLAG_STRING;
@@ -558,8 +552,17 @@ print_flowspec_flags(struct flowspec *f, int type, int is_v6)
else
flags = FLOWSPEC_FRAG_STRING6;
break;
+ default:
+ printf("??? ");
+ return;
}
+ if (flowspec_get_component(f->data, f->len, type, is_v6,
+ &comp, &complen) != 1)
+ return;
+
+ printf("%s ", flowspec_fmt_label(type));
+
fmt = flowspec_fmt_bin_op(comp, complen, &off, flags);
if (off == -1) {
printf("%s ", fmt);