diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2012-06-14 20:59:43 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2012-06-14 20:59:43 +0000 |
commit | 26dfcf665c8702591d32420057e4dfa42b3b0678 (patch) | |
tree | 65d5ee8e7e6fd9c87f0091988f905e41eaf9b3a4 /usr.sbin | |
parent | 1353018553f3635c0b78e8478cfcba87d0d80a3f (diff) |
- make sockaddr_as_fqdn() endian-safe
bug spotted by Jan Stary
fix by eric@, committing this on his behalf, ok gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/sockaddr.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/smtpd/sockaddr.c b/usr.sbin/smtpd/sockaddr.c index da9a04a001b..bc918ffc6d3 100644 --- a/usr.sbin/smtpd/sockaddr.c +++ b/usr.sbin/smtpd/sockaddr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sockaddr.c,v 1.4 2011/05/16 10:57:41 blambert Exp $ */ +/* $OpenBSD: sockaddr.c,v 1.5 2012/06/14 20:59:42 gilles Exp $ */ /* * Copyright (c) 2010 Eric Faurot <eric@faurot.net> * @@ -114,13 +114,13 @@ sockaddr_as_fqdn(const struct sockaddr *sa, char *dst, size_t max) switch (sa->sa_family) { case AF_INET: - addr = ((const struct sockaddr_in *)sa)->sin_addr.s_addr; + addr = ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr); snprintf(dst, max, "%d.%d.%d.%d.in-addr.arpa.", - (addr >> 24) & 0xff, - (addr >> 16) & 0xff, + addr & 0xff, (addr >> 8) & 0xff, - addr & 0xff); + (addr >> 16) & 0xff, + (addr >> 24) & 0xff); break; case AF_INET6: in6_addr = &((const struct sockaddr_in6 *)sa)->sin6_addr; |