Add default: cases in some switches to detect if shit goes very badly
wrong. Right now these code paths are unreachable since the callers of
these functions never use a value that is not covered in the switch() but
gcc is not smart enough for that.
--
:wq Claudio
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.453
diff -u -p -r1.453 parse.y
--- parse.y 26 Apr 2023 18:14:28 -0000 1.453
+++ parse.y 28 Apr 2023 13:07:35 -0000
@@ -5683,6 +5683,9 @@ push_prefix(struct bgpd_addr *addr, uint
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) {
Index: printconf.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/printconf.c,v
retrieving revision 1.166
diff -u -p -r1.166 printconf.c
--- printconf.c 21 Apr 2023 10:48:33 -0000 1.166
+++ printconf.c 28 Apr 2023 13:10:49 -0000
@@ -542,12 +542,6 @@ print_flowspec_flags(struct flowspec *f,
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,7 +552,16 @@ print_flowspec_flags(struct flowspec *f,
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) {