summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2012-09-14 19:20:52 +0000
committereric <eric@openbsd.org>2012-09-14 19:20:52 +0000
commit05a218a63fb5bbe20598dfc9fc5463c957831fd0 (patch)
tree4442838e39401495e5927531c6a8fd4421aaef1e
parenttweak the description of "value" somewhat; ok gilles (diff)
downloadwireguard-openbsd-05a218a63fb5bbe20598dfc9fc5463c957831fd0.tar.xz
wireguard-openbsd-05a218a63fb5bbe20598dfc9fc5463c957831fd0.zip
When printing ioev, do not segfault if there is no associated iobuf.
Also give info about the cipher if there is an ssl context. ok chl@ gilles@
-rw-r--r--usr.sbin/smtpd/ioev.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/usr.sbin/smtpd/ioev.c b/usr.sbin/smtpd/ioev.c
index 2345a256ef2..2b6f5bc65d0 100644
--- a/usr.sbin/smtpd/ioev.c
+++ b/usr.sbin/smtpd/ioev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioev.c,v 1.4 2012/08/19 10:28:28 eric Exp $ */
+/* $OpenBSD: ioev.c,v 1.5 2012/09/14 19:20:52 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -82,10 +82,28 @@ const char*
io_strio(struct io *io)
{
static char buf[128];
+ char ssl[128];
+
+ ssl[0] = '\0';
+#ifdef IO_SSL
+ if (io->ssl) {
+ snprintf(ssl, sizeof ssl, " ssl=%s:%s:%i",
+ SSL_get_cipher_version(io->ssl),
+ SSL_get_cipher_name(io->ssl),
+ SSL_get_cipher_bits(io->ssl, NULL));
+ }
+#endif
+
+ if (io->iobuf == NULL)
+ snprintf(buf, sizeof buf,
+ "<io:%p fd=%i to=%i fl=%s%s>",
+ io, io->sock, io->timeout, io_strflags(io->flags), ssl);
+ else
+ snprintf(buf, sizeof buf,
+ "<io:%p fd=%i to=%i fl=%s%s ib=%zu ob=%zu>",
+ io, io->sock, io->timeout, io_strflags(io->flags), ssl,
+ io_pending(io), io_queued(io));
- snprintf(buf, sizeof buf, "<io:%p fd=%i to=%i fl=%s ib=%zu ob=%zu>",
- io, io->sock, io->timeout, io_strflags(io->flags),
- io_pending(io), io_queued(io));
return (buf);
}