summaryrefslogtreecommitdiff
path: root/usr.bin/dig/lib
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2020-09-15 11:46:21 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2020-09-15 11:46:21 +0000
commit47547dc66f7274ffcc3d179a96c436d3c28a7fc3 (patch)
treeb7f88c15081a507a571ae4f7ad38903816457405 /usr.bin/dig/lib
parent5a84cfb12ce368976a1d011587ce96e45fc88fc9 (diff)
The various sockaddr structures have length fields these days.
OK beck
Diffstat (limited to 'usr.bin/dig/lib')
-rw-r--r--usr.bin/dig/lib/isc/include/isc/sockaddr.h3
-rw-r--r--usr.bin/dig/lib/isc/sockaddr.c10
-rw-r--r--usr.bin/dig/lib/isc/unix/socket.c8
3 files changed, 8 insertions, 13 deletions
diff --git a/usr.bin/dig/lib/isc/include/isc/sockaddr.h b/usr.bin/dig/lib/isc/include/isc/sockaddr.h
index 5563af090fc..a8b114bb676 100644
--- a/usr.bin/dig/lib/isc/include/isc/sockaddr.h
+++ b/usr.bin/dig/lib/isc/include/isc/sockaddr.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: sockaddr.h,v 1.5 2020/09/14 08:40:44 florian Exp $ */
+/* $Id: sockaddr.h,v 1.6 2020/09/15 11:46:19 florian Exp $ */
#ifndef ISC_SOCKADDR_H
#define ISC_SOCKADDR_H 1
@@ -36,7 +36,6 @@ struct isc_sockaddr {
struct sockaddr_storage ss;
struct sockaddr_un sunix;
} type;
- unsigned int length; /* XXXRTH beginning? */
};
#define ISC_SOCKADDR_CMPADDR 0x0001 /*%< compare the address
diff --git a/usr.bin/dig/lib/isc/sockaddr.c b/usr.bin/dig/lib/isc/sockaddr.c
index 911653ec6a0..ee2cd7f5300 100644
--- a/usr.bin/dig/lib/isc/sockaddr.c
+++ b/usr.bin/dig/lib/isc/sockaddr.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: sockaddr.c,v 1.11 2020/09/15 08:19:29 florian Exp $ */
+/* $Id: sockaddr.c,v 1.12 2020/09/15 11:46:19 florian Exp $ */
/*! \file */
#include <sys/types.h>
@@ -48,7 +48,7 @@ isc_sockaddr_compare(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
{
REQUIRE(a != NULL && b != NULL);
- if (a->length != b->length)
+ if (a->type.ss.ss_len != b->type.ss.ss_len)
return (0);
/*
@@ -88,7 +88,7 @@ isc_sockaddr_compare(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
return (0);
break;
default:
- if (memcmp(&a->type, &b->type, a->length) != 0)
+ if (memcmp(&a->type, &b->type, a->type.ss.ss_len) != 0)
return (0);
}
return (1);
@@ -169,7 +169,6 @@ isc_sockaddr_any(isc_sockaddr_t *sockaddr)
sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
sockaddr->type.sin.sin_addr.s_addr = INADDR_ANY;
sockaddr->type.sin.sin_port = 0;
- sockaddr->length = sizeof(sockaddr->type.sin);
}
void
@@ -180,7 +179,6 @@ isc_sockaddr_any6(isc_sockaddr_t *sockaddr)
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
sockaddr->type.sin6.sin6_addr = in6addr_any;
sockaddr->type.sin6.sin6_port = 0;
- sockaddr->length = sizeof(sockaddr->type.sin6);
}
void
@@ -192,7 +190,6 @@ isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
sockaddr->type.sin.sin_addr = *ina;
sockaddr->type.sin.sin_port = htons(port);
- sockaddr->length = sizeof(sockaddr->type.sin);
}
void
@@ -218,7 +215,6 @@ isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, const struct in6_addr *ina6,
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
sockaddr->type.sin6.sin6_addr = *ina6;
sockaddr->type.sin6.sin6_port = htons(port);
- sockaddr->length = sizeof(sockaddr->type.sin6);
}
int
diff --git a/usr.bin/dig/lib/isc/unix/socket.c b/usr.bin/dig/lib/isc/unix/socket.c
index 42aad2efae6..4e3a77d317f 100644
--- a/usr.bin/dig/lib/isc/unix/socket.c
+++ b/usr.bin/dig/lib/isc/unix/socket.c
@@ -506,7 +506,7 @@ build_msghdr_send(isc_socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
if (!sock->connected) {
msg->msg_name = (void *)&dev->address.type.sa;
- msg->msg_namelen = dev->address.length;
+ msg->msg_namelen = dev->address.type.ss.ss_len;
} else {
msg->msg_name = NULL;
msg->msg_namelen = 0;
@@ -910,7 +910,7 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
}
if (sock->type == isc_sockettype_udp) {
- dev->address.length = msghdr.msg_namelen;
+ dev->address.type.ss.ss_len = msghdr.msg_namelen;
if (isc_sockaddr_getport(&dev->address) == 0) {
if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) {
socket_log(sock, &dev->address, IOEVENT,
@@ -2189,7 +2189,7 @@ isc_socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
"setsockopt(%d) %s", sock->fd, "failed");
/* Press on... */
}
- if (bind(sock->fd, &sockaddr->type.sa, sockaddr->length) < 0) {
+ if (bind(sock->fd, &sockaddr->type.sa, sockaddr->type.sa.sa_len) < 0) {
switch (errno) {
case EACCES:
return (ISC_R_NOPERM);
@@ -2249,7 +2249,7 @@ isc_socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
* outstanding, and it might happen to complete.
*/
sock->peer_address = *addr;
- cc = connect(sock->fd, &addr->type.sa, addr->length);
+ cc = connect(sock->fd, &addr->type.sa, addr->type.sa.sa_len);
if (cc < 0) {
/*
* HP-UX "fails" to connect a UDP socket and sets errno to