From f3c6d21c3e8d8b1cf6fe1780cb45a0177b23c5b6 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sat, 15 Dec 2012 13:40:57 +0000 Subject: [PATCH] server/admin.c, server/tripe-admin.5.in: Fix PEERINFO segfault. Organization: Straylight/Edgeware From: Mark Wooding It's allowed for p_privtag to return null, so just trying to print it is a bad idea. This introduces a protocol change, since there is no single tag chosen in the absence of `-priv' or `-t' options -- instead, there's a search list; this is represented with the special tag `(default)'. --- server/admin.c | 4 +++- server/tripe-admin.5.in | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/admin.c b/server/admin.c index 0e3effb0..487010e1 100644 --- a/server/admin.c +++ b/server/admin.c @@ -1831,13 +1831,15 @@ static void acmd_peerinfo(admin *a, unsigned ac, char *av[]) { peer *p; const peerspec *ps; + const char *ptag; if ((p = a_findpeer(a, av[0])) != 0) { ps = p_spec(p); a_info(a, "tunnel=%s", ps->tops->name, A_END); a_info(a, "key=%s", p_tag(p), "current-key=%s", p->kx.kpub->tag, A_END); - a_info(a, "private-key=%s", p_privtag(p), + if ((ptag = p_privtag(p)) == 0) ptag = "(default)"; + a_info(a, "private-key=%s", ptag, "current-private-key=%s", p->kx.kpriv->tag, A_END); a_info(a, "keepalive=%lu", ps->t_ka, A_END); a_ok(a); diff --git a/server/tripe-admin.5.in b/server/tripe-admin.5.in index 3f13de4a..7b801740 100644 --- a/server/tripe-admin.5.in +++ b/server/tripe-admin.5.in @@ -570,7 +570,12 @@ may change during the life of the association. .B private-key The private key tag being used for the peer, as passed to the .B ADD -command. +command, or the +.RB ` \-t ' +command-line option. If neither of these was given explicitly, the +private key tag is shown as +.RB ` (default) ', +since there is no fixed tag used under these circumstances. .TP .B current-private-key The full key tag of the private key currently being used for this -- [mdw]