summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/smtpd/mta_session.c8
-rw-r--r--usr.sbin/smtpd/smtpd.h3
-rw-r--r--usr.sbin/smtpd/util.c29
3 files changed, 8 insertions, 32 deletions
diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c
index 9a6d12e6288..a5a00d6823c 100644
--- a/usr.sbin/smtpd/mta_session.c
+++ b/usr.sbin/smtpd/mta_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta_session.c,v 1.37 2013/06/03 16:04:03 eric Exp $ */
+/* $OpenBSD: mta_session.c,v 1.38 2013/07/19 07:37:29 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -479,7 +479,11 @@ mta_connect(struct mta_session *s)
memmove(&ss, s->route->dst->sa, s->route->dst->sa->sa_len);
sa = (struct sockaddr *)&ss;
- sa_set_port(sa, portno);
+
+ if (sa->sa_family == AF_INET)
+ ((struct sockaddr_in *)sa)->sin_port = htons(portno);
+ else if (sa->sa_family == AF_INET6)
+ ((struct sockaddr_in6 *)sa)->sin6_port = htons(portno);
s->attempt += 1;
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index a912002cce1..8999fc093d8 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.411 2013/06/04 08:42:00 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.412 2013/07/19 07:37:29 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1364,7 +1364,6 @@ int valid_domainpart(const char *);
int secure_file(int, char *, char *, uid_t, int);
int lowercase(char *, const char *, size_t);
void xlowercase(char *, const char *, size_t);
-void sa_set_port(struct sockaddr *, int);
uint64_t generate_uid(void);
void fdlimit(double);
int availdesc(void);
diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c
index 97078c766db..453706821ea 100644
--- a/usr.sbin/smtpd/util.c
+++ b/usr.sbin/smtpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.94 2013/05/24 17:03:14 eric Exp $ */
+/* $OpenBSD: util.c,v 1.95 2013/07/19 07:37:29 eric Exp $ */
/*
* Copyright (c) 2000,2001 Markus Friedl. All rights reserved.
@@ -606,33 +606,6 @@ xlowercase(char *buf, const char *s, size_t len)
fatalx("lowercase: truncation");
}
-void
-sa_set_port(struct sockaddr *sa, int port)
-{
- char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
- struct addrinfo hints, *res;
- int error;
-
- error = getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0,
- NI_NUMERICHOST);
- if (error)
- fatalx("sa_set_port: getnameinfo failed");
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = PF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_NUMERICHOST|AI_NUMERICSERV;
-
- snprintf(sbuf, sizeof(sbuf), "%d", port);
-
- error = getaddrinfo(hbuf, sbuf, &hints, &res);
- if (error)
- fatalx("sa_set_port: getaddrinfo failed");
-
- memcpy(sa, res->ai_addr, res->ai_addrlen);
- freeaddrinfo(res);
-}
-
uint64_t
generate_uid(void)
{