From 0640655c0ba01770ced9bffd6bc78c0e5b2b553b Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 11 Dec 2018 07:57:31 +0000 Subject: [PATCH] remove unnecessary calls to getsockname() ok gilles@ --- usr.sbin/smtpd/smtp_session.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index ac8b590a1ed..0c389cbf042 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.366 2018/12/09 17:37:15 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.367 2018/12/11 07:57:31 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -1947,25 +1947,13 @@ abort: static void smtp_lookup_servername(struct smtp_session *s) { - struct sockaddr *sa; - socklen_t sa_len; - struct sockaddr_storage ss; - if (s->listener->hostnametable[0]) { - sa_len = sizeof(ss); - sa = (struct sockaddr *)&ss; - if (getsockname(io_fileno(s->io), sa, &sa_len) == -1) { - log_warn("warn: getsockname()"); - } - else { - m_create(p_lka, IMSG_SMTP_LOOKUP_HELO, 0, 0, -1); - m_add_id(p_lka, s->id); - m_add_string(p_lka, s->listener->hostnametable); - m_add_sockaddr(p_lka, sa); - m_close(p_lka); - tree_xset(&wait_lka_helo, s->id, s); - return; - } + m_create(p_lka, IMSG_SMTP_LOOKUP_HELO, 0, 0, -1); + m_add_id(p_lka, s->id); + m_add_string(p_lka, s->listener->hostnametable); + m_add_sockaddr(p_lka, (struct sockaddr*)&s->ss); + m_close(p_lka); + tree_xset(&wait_lka_helo, s->id, s); } smtp_connected(s); @@ -1974,9 +1962,6 @@ smtp_lookup_servername(struct smtp_session *s) static void smtp_connected(struct smtp_session *s) { - struct sockaddr_storage ss; - socklen_t sl; - smtp_enter_state(s, STATE_CONNECTED); log_info("%016"PRIx64" smtp connected address=%s host=%s", @@ -1985,12 +1970,6 @@ smtp_connected(struct smtp_session *s) smtp_report_link_connect(s->id, s->hostname, s->fcrdns, &s->ss, &s->listener->ss); - sl = sizeof(ss); - if (getsockname(io_fileno(s->io), (struct sockaddr*)&ss, &sl) == -1) { - smtp_free(s, strerror(errno)); - return; - } - smtp_filter_begin(s); smtp_filter_phase(FILTER_CONNECTED, s, ss_to_text(&s->ss)); } -- 2.20.1