Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/ldpd Make sure there is enough space for sockaddr s...
details: https://anonhg.NetBSD.org/src/rev/45a141bb1f45
branches: trunk
changeset: 784049:45a141bb1f45
user: kefren <kefren%NetBSD.org@localhost>
date: Wed Jan 16 08:28:44 2013 +0000
description:
Make sure there is enough space for sockaddr subtypes
Use u_char for IP_MULTICAST_LOOP as specified in in.h
diffstat:
usr.sbin/ldpd/mpls_routes.h | 3 ++-
usr.sbin/ldpd/socketops.c | 28 +++++++++++++---------------
2 files changed, 15 insertions(+), 16 deletions(-)
diffs (75 lines):
diff -r 3b43d9ef3817 -r 45a141bb1f45 usr.sbin/ldpd/mpls_routes.h
--- a/usr.sbin/ldpd/mpls_routes.h Wed Jan 16 06:45:24 2013 +0000
+++ b/usr.sbin/ldpd/mpls_routes.h Wed Jan 16 08:28:44 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpls_routes.h,v 1.1 2010/12/08 07:20:15 kefren Exp $ */
+/* $NetBSD: mpls_routes.h,v 1.2 2013/01/16 08:28:44 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -49,6 +49,7 @@
union sockunion {
struct sockaddr sa;
struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
struct sockaddr_mpls smpls;
struct sockaddr_dl sdl;
};
diff -r 3b43d9ef3817 -r 45a141bb1f45 usr.sbin/ldpd/socketops.c
--- a/usr.sbin/ldpd/socketops.c Wed Jan 16 06:45:24 2013 +0000
+++ b/usr.sbin/ldpd/socketops.c Wed Jan 16 08:28:44 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socketops.c,v 1.15 2012/11/13 06:58:58 kefren Exp $ */
+/* $NetBSD: socketops.c,v 1.16 2013/01/16 08:28:45 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -147,8 +147,8 @@
#endif
/* We don't need to receive back our messages */
- if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &(uint8_t){0},
- sizeof(uint8_t)) == -1) {
+ if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &(u_char){0},
+ sizeof(u_char)) == -1) {
fatalp("INET setsockopt IP_MCAST_LOOP: %s\n", strerror(errno));
goto chs_error;
}
@@ -260,27 +260,25 @@
static int
bind_socket(int s, uint8_t stype)
{
- struct sockaddr sa;
+ union sockunion su;
assert (stype == 4 || stype == 6);
if (stype == 4) {
- struct sockaddr_in *sa_inet = (struct sockaddr_in *)(&sa);
- sa_inet->sin_len = sizeof(*sa_inet);
- sa_inet->sin_family = AF_INET;
- sa_inet->sin_addr.s_addr = INADDR_ANY;
- sa_inet->sin_port = htons(LDP_PORT);
+ su.sin.sin_len = sizeof(su.sin);
+ su.sin.sin_family = AF_INET;
+ su.sin.sin_addr.s_addr = INADDR_ANY;
+ su.sin.sin_port = htons(LDP_PORT);
}
#ifdef INET6
else if (stype == 6) {
- struct sockaddr_in6 *sa_inet6 = (struct sockaddr_in6 *)(&sa);
- sa_inet6->sin6_len = sizeof(*sa_inet6);
- sa_inet6->sin6_family = AF_INET6;
- sa_inet6->sin6_addr = in6addr_any;
- sa_inet6->sin6_port = htons(LDP_PORT);
+ su.sin6.sin6_len = sizeof(su.sin6);
+ su.sin6.sin6_family = AF_INET6;
+ su.sin6.sin6_addr = in6addr_any;
+ su.sin6.sin6_port = htons(LDP_PORT);
}
#endif
- if (bind(s, &sa, sa.sa_len)) {
+ if (bind(s, &su.sa, su.sa.sa_len)) {
fatalp("bind_socket: %s\n", strerror(errno));
return -1;
}
Home |
Main Index |
Thread Index |
Old Index