summaryrefslogtreecommitdiff
path: root/usr.sbin/rpki-client/print.c
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2024-02-01 15:11:39 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2024-02-01 15:11:39 +0000
commit52f42ad7a9f06ba7d1e38c83248f7374ccb5eaec (patch)
tree47b0dad9f016474a6e54ac5d9576363b6bbc2e18 /usr.sbin/rpki-client/print.c
parent25e467d7d6b4e674a3da6a01b3b175b83937c70c (diff)
Normalize the nid printing
OBJ_nid2* can return NULL if the gloriously consistent objects.txt database doesn't specify a long or a short name. So try the long name first, fall back to the short name, and if both fail, use "unknown". Always include the nid as a decimal. ok claudio
Diffstat (limited to 'usr.sbin/rpki-client/print.c')
-rw-r--r--usr.sbin/rpki-client/print.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.sbin/rpki-client/print.c b/usr.sbin/rpki-client/print.c
index 03112fe7bd2..9395cd00880 100644
--- a/usr.sbin/rpki-client/print.c
+++ b/usr.sbin/rpki-client/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.45 2024/01/18 14:34:26 job Exp $ */
+/* $OpenBSD: print.c,v 1.46 2024/02/01 15:11:38 tb Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -50,6 +50,22 @@ pretty_key_id(const char *hex)
}
char *
+nid2str(int nid)
+{
+ static char buf[128];
+ const char *name;
+
+ if ((name = OBJ_nid2ln(nid)) == NULL)
+ name = OBJ_nid2sn(nid);
+ if (name == NULL)
+ name = "unknown";
+
+ snprintf(buf, sizeof(buf), "nid %d (%s)", nid, name);
+
+ return buf;
+}
+
+char *
time2str(time_t t)
{
static char buf[64];