summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorho <ho@openbsd.org>2002-09-19 16:22:33 +0000
committerho <ho@openbsd.org>2002-09-19 16:22:33 +0000
commit55b145bd7a38016bf8f1a4c730bb03897084f9ce (patch)
treef3194cc30fb2a6818ccbb208cfaa3f7817503747
parentlog IP address also; ok markus@ (diff)
downloadwireguard-openbsd-55b145bd7a38016bf8f1a4c730bb03897084f9ce.tar.xz
wireguard-openbsd-55b145bd7a38016bf8f1a4c730bb03897084f9ce.zip
Don't print garbage when getnameinfo fails. henning@ ok.
-rw-r--r--usr.bin/netstat/route.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 01ad68910d4..d3bebd01670 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.47 2002/07/25 03:58:56 deraadt Exp $ */
+/* $OpenBSD: route.c,v 1.48 2002/09/19 16:22:33 ho Exp $ */
/* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
#else
-static char *rcsid = "$OpenBSD: route.c,v 1.47 2002/07/25 03:58:56 deraadt Exp $";
+static char *rcsid = "$OpenBSD: route.c,v 1.48 2002/09/19 16:22:33 ho Exp $";
#endif
#endif /* not lint */
@@ -1058,8 +1058,10 @@ encap_print(rt)
kget(sen3.sen_ipsp, ipo);
- getnameinfo(&ipo.ipo_dst.sa, ipo.ipo_dst.sa.sa_len,
- hostn, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
+ if (getnameinfo(&ipo.ipo_dst.sa, ipo.ipo_dst.sa.sa_len,
+ hostn, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) != 0)
+ strlcpy (hostn, "none", NI_MAXHOST);
+
printf("%s", hostn);
printf("/%-u", ipo.ipo_sproto);