summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-09-30 12:54:13 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-09-30 12:54:13 +0000
commit1d6092d2b71ba7f1a589cb00bf0d4becdffffde5 (patch)
tree184e5b02b978c5b581cbd78dc99014c19f62f306
parentafe7c7caafe1295fb7c939b94be5191102f27fec (diff)
Improve some currently impossible error path in log_ext_subtype().
Mainly handle unknown ext-communities better and handle the special case of type == -1. OK tb@
-rw-r--r--usr.sbin/bgpd/util.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/util.c b/usr.sbin/bgpd/util.c
index 1a99e426f5d..257c7ad59a2 100644
--- a/usr.sbin/bgpd/util.c
+++ b/usr.sbin/bgpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.87 2024/07/03 08:39:43 job Exp $ */
+/* $OpenBSD: util.c,v 1.88 2024/09/30 12:54:12 claudio Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -161,14 +161,16 @@ const struct ext_comm_pairs iana_ext_comms[] = IANA_EXT_COMMUNITIES;
const char *
log_ext_subtype(int type, uint8_t subtype)
{
- static char etype[6];
+ static char etype[16];
const struct ext_comm_pairs *cp;
for (cp = iana_ext_comms; cp->subname != NULL; cp++) {
if ((type == cp->type || type == -1) && subtype == cp->subtype)
return (cp->subname);
}
- snprintf(etype, sizeof(etype), "[%u]", subtype);
+ if (type == -1)
+ return ("???");
+ snprintf(etype, sizeof(etype), "[%hhx:%hhx]", (uint8_t)type, subtype);
return (etype);
}