summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/mta_session.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2013-07-22 13:11:12 +0000
committerEric Faurot <eric@cvs.openbsd.org>2013-07-22 13:11:12 +0000
commit865f569263f8c8e08464d58edbae4a8c94ed1354 (patch)
tree2935f97f7b4c47363a9dce07fbdec80453971f38 /usr.sbin/smtpd/mta_session.c
parent63f47fdd5793f96b1d45fc0bd3dc358786fba41e (diff)
fix sockaddr overflow with IPv6
Diffstat (limited to 'usr.sbin/smtpd/mta_session.c')
-rw-r--r--usr.sbin/smtpd/mta_session.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c
index e3c8896c96d..6d8544bc107 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.39 2013/07/19 21:14:52 eric Exp $ */
+/* $OpenBSD: mta_session.c,v 1.40 2013/07/22 13:11:11 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -761,7 +761,8 @@ mta_response(struct mta_session *s, char *line)
{
struct mta_envelope *e;
struct failed_evp *fevp;
- struct sockaddr sa;
+ struct sockaddr_storage ss;
+ struct sockaddr *sa;
const char *domain;
socklen_t sa_len;
char buf[SMTPD_MAXLINESIZE];
@@ -888,11 +889,12 @@ mta_response(struct mta_session *s, char *line)
* getsockname() can only fail with ENOBUFS here
* best effort, don't log source ...
*/
- sa_len = sizeof sa;
- if (getsockname(s->io.sock, &sa, &sa_len) < 0)
+ sa_len = sizeof(ss);
+ sa = (struct sockaddr *)&ss;
+ if (getsockname(s->io.sock, sa, &sa_len) < 0)
mta_delivery_log(e, NULL, buf, delivery, line);
else
- mta_delivery_log(e, sa_to_text(&sa),
+ mta_delivery_log(e, sa_to_text(sa),
buf, delivery, line);
/* push failed envelope to the session fail queue */
@@ -1219,7 +1221,8 @@ mta_flush_task(struct mta_session *s, int delivery, const char *error, size_t co
struct mta_envelope *e;
char relay[SMTPD_MAXLINESIZE];
size_t n;
- struct sockaddr sa;
+ struct sockaddr_storage ss;
+ struct sockaddr *sa;
socklen_t sa_len;
const char *domain;
@@ -1242,11 +1245,12 @@ mta_flush_task(struct mta_session *s, int delivery, const char *error, size_t co
* getsockname() can only fail with ENOBUFS here
* best effort, don't log source ...
*/
- sa_len = sizeof sa;
- if (getsockname(s->io.sock, &sa, &sa_len) < 0)
+ sa = (struct sockaddr *)&ss;
+ sa_len = sizeof(ss);
+ if (getsockname(s->io.sock, sa, &sa_len) < 0)
mta_delivery(e, NULL, relay, delivery, error, 0);
else
- mta_delivery(e, sa_to_text(&sa),
+ mta_delivery(e, sa_to_text(sa),
relay, delivery, error, 0);
domain = strchr(e->dest, '@');