summaryrefslogtreecommitdiffstats
path: root/netwerk/sctp/src
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk/sctp/src')
-rw-r--r--netwerk/sctp/src/ifaddrs-android-ext.h62
-rw-r--r--netwerk/sctp/src/ifaddrs_android.cpp189
-rw-r--r--netwerk/sctp/src/moz.build14
-rwxr-xr-xnetwerk/sctp/src/netinet/sctp.h7
-rwxr-xr-xnetwerk/sctp/src/netinet/sctp_auth.c5
-rwxr-xr-xnetwerk/sctp/src/netinet/sctp_bsd_addr.c6
-rwxr-xr-xnetwerk/sctp/src/netinet/sctp_os_userspace.h2
-rwxr-xr-xnetwerk/sctp/src/netinet/sctp_pcb.c7
-rwxr-xr-xnetwerk/sctp/src/netinet/sctp_usrreq.c14
9 files changed, 28 insertions, 278 deletions
diff --git a/netwerk/sctp/src/ifaddrs-android-ext.h b/netwerk/sctp/src/ifaddrs-android-ext.h
deleted file mode 100644
index abddae735..000000000
--- a/netwerk/sctp/src/ifaddrs-android-ext.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef IFADDRS_ANDROID_EXT_H_included
-#define IFADDRS_ANDROID_EXT_H_included
-
-#include <arpa/inet.h>
-#include <errno.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdio.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-
-// Android (bionic) doesn't have getifaddrs(3)/freeifaddrs(3).
-// We fake it here, so java_net_NetworkInterface.cpp can use that API
-// with all the non-portable code being in this file.
-
-// Source-compatible subset of the BSD struct.
-typedef struct ifaddrs {
- // Pointer to next struct in list, or NULL at end.
- struct ifaddrs* ifa_next;
-
- // Interface name.
- char* ifa_name;
-
- // Interface flags.
- unsigned int ifa_flags;
-
- // Interface network address.
- struct sockaddr* ifa_addr;
-
- // Interface netmask.
- struct sockaddr* ifa_netmask;
-} ifaddrs;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- int getifaddrs(ifaddrs** result);
- void freeifaddrs(ifaddrs* addresses);
-#ifdef __cplusplus
-}
-#endif
-
-#endif // IFADDRS_ANDROID_H_included
diff --git a/netwerk/sctp/src/ifaddrs_android.cpp b/netwerk/sctp/src/ifaddrs_android.cpp
deleted file mode 100644
index 78eb90a1a..000000000
--- a/netwerk/sctp/src/ifaddrs_android.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ifaddrs-android-ext.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include "ScopedFd.h"
-#include "LocalArray.h"
-
-// Returns a pointer to the first byte in the address data (which is
-// stored in network byte order).
-uint8_t* sockaddrBytes(int family, sockaddr_storage* ss) {
- if (family == AF_INET) {
- sockaddr_in* ss4 = reinterpret_cast<sockaddr_in*>(ss);
- return reinterpret_cast<uint8_t*>(&ss4->sin_addr);
- } else if (family == AF_INET6) {
- sockaddr_in6* ss6 = reinterpret_cast<sockaddr_in6*>(ss);
- return reinterpret_cast<uint8_t*>(&ss6->sin6_addr);
- }
- return NULL;
-}
-
-// Sadly, we can't keep the interface index for portability with BSD.
-// We'll have to keep the name instead, and re-query the index when
-// we need it later.
-bool ifa_setNameAndFlagsByIndex(ifaddrs *self, int interfaceIndex) {
- // Get the name.
- char buf[IFNAMSIZ];
- char* name = if_indextoname(interfaceIndex, buf);
- if (name == NULL) {
- return false;
- }
- self->ifa_name = new char[strlen(name) + 1];
- strcpy(self->ifa_name, name);
-
- // Get the flags.
- ScopedFd fd(socket(AF_INET, SOCK_DGRAM, 0));
- if (fd.get() == -1) {
- return false;
- }
- ifreq ifr;
- memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, name);
- int rc = ioctl(fd.get(), SIOCGIFFLAGS, &ifr);
- if (rc == -1) {
- return false;
- }
- self->ifa_flags = ifr.ifr_flags;
- return true;
-}
-
-// Netlink gives us the address family in the header, and the
-// sockaddr_in or sockaddr_in6 bytes as the payload. We need to
-// stitch the two bits together into the sockaddr that's part of
-// our portable interface.
-void ifa_setAddress(ifaddrs *self, int family, void* data, size_t byteCount) {
- // Set the address proper...
- sockaddr_storage* ss = new sockaddr_storage;
- memset(ss, 0, sizeof(*ss));
- self->ifa_addr = reinterpret_cast<sockaddr*>(ss);
- ss->ss_family = family;
- uint8_t* dst = sockaddrBytes(family, ss);
- memcpy(dst, data, byteCount);
-}
-
-// Netlink gives us the prefix length as a bit count. We need to turn
-// that into a BSD-compatible netmask represented by a sockaddr*.
-void ifa_setNetmask(ifaddrs *self, int family, size_t prefixLength) {
- // ...and work out the netmask from the prefix length.
- sockaddr_storage* ss = new sockaddr_storage;
- memset(ss, 0, sizeof(*ss));
- self->ifa_netmask = reinterpret_cast<sockaddr*>(ss);
- ss->ss_family = family;
- uint8_t* dst = sockaddrBytes(family, ss);
- memset(dst, 0xff, prefixLength / 8);
- if ((prefixLength % 8) != 0) {
- dst[prefixLength/8] = (0xff << (8 - (prefixLength % 8)));
- }
-}
-
-// FIXME: use iovec instead.
-struct addrReq_struct {
- nlmsghdr netlinkHeader;
- ifaddrmsg msg;
-};
-
-inline bool sendNetlinkMessage(int fd, const void* data, size_t byteCount) {
- ssize_t sentByteCount = TEMP_FAILURE_RETRY(send(fd, data, byteCount, 0));
- return (sentByteCount == static_cast<ssize_t>(byteCount));
-}
-
-inline ssize_t recvNetlinkMessage(int fd, char* buf, size_t byteCount) {
- return TEMP_FAILURE_RETRY(recv(fd, buf, byteCount, 0));
-}
-
-// Source-compatible with the BSD function.
-int getifaddrs(ifaddrs** result)
-{
- // Simplify cleanup for callers.
- *result = NULL;
-
- // Create a netlink socket.
- ScopedFd fd(socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE));
- if (fd.get() < 0) {
- return -1;
- }
-
- // Ask for the address information.
- addrReq_struct addrRequest;
- memset(&addrRequest, 0, sizeof(addrRequest));
- addrRequest.netlinkHeader.nlmsg_flags = NLM_F_REQUEST | NLM_F_MATCH;
- addrRequest.netlinkHeader.nlmsg_type = RTM_GETADDR;
- addrRequest.netlinkHeader.nlmsg_len = NLMSG_ALIGN(NLMSG_LENGTH(sizeof(addrRequest)));
- addrRequest.msg.ifa_family = AF_UNSPEC; // All families.
- addrRequest.msg.ifa_index = 0; // All interfaces.
- if (!sendNetlinkMessage(fd.get(), &addrRequest, addrRequest.netlinkHeader.nlmsg_len)) {
- return -1;
- }
-
- // Read the responses.
- LocalArray<0> buf(65536); // We don't necessarily have std::vector.
- ssize_t bytesRead;
- while ((bytesRead = recvNetlinkMessage(fd.get(), &buf[0], buf.size())) > 0) {
- nlmsghdr* hdr = reinterpret_cast<nlmsghdr*>(&buf[0]);
- for (; NLMSG_OK(hdr, (size_t)bytesRead); hdr = NLMSG_NEXT(hdr, bytesRead)) {
- switch (hdr->nlmsg_type) {
- case NLMSG_DONE:
- return 0;
- case NLMSG_ERROR:
- return -1;
- case RTM_NEWADDR:
- {
- ifaddrmsg* address = reinterpret_cast<ifaddrmsg*>(NLMSG_DATA(hdr));
- rtattr* rta = IFA_RTA(address);
- size_t ifaPayloadLength = IFA_PAYLOAD(hdr);
- while (RTA_OK(rta, ifaPayloadLength)) {
- if (rta->rta_type == IFA_LOCAL) {
- int family = address->ifa_family;
- if (family == AF_INET || family == AF_INET6) {
- ifaddrs *next = *result;
- *result = new ifaddrs;
- memset(*result, 0, sizeof(ifaddrs));
- (*result)->ifa_next = next;
- if (!ifa_setNameAndFlagsByIndex(*result, address->ifa_index)) {
- return -1;
- }
- ifa_setAddress(*result, family, RTA_DATA(rta), RTA_PAYLOAD(rta));
- ifa_setNetmask(*result, family, address->ifa_prefixlen);
- }
- }
- rta = RTA_NEXT(rta, ifaPayloadLength);
- }
- }
- break;
- }
- }
- }
- // We only get here if recv fails before we see a NLMSG_DONE.
- return -1;
-}
-
-// Source-compatible with the BSD function.
-void freeifaddrs(ifaddrs* addresses) {
- ifaddrs* self = addresses;
- while (self != NULL) {
- delete[] self->ifa_name;
- delete self->ifa_addr;
- delete self->ifa_netmask;
- ifaddrs* next = self->ifa_next;
- delete self;
- self = next;
- }
-}
diff --git a/netwerk/sctp/src/moz.build b/netwerk/sctp/src/moz.build
index f24702fee..40a91eec1 100644
--- a/netwerk/sctp/src/moz.build
+++ b/netwerk/sctp/src/moz.build
@@ -34,11 +34,6 @@ SOURCES += [
'user_socket.c',
]
-if CONFIG['OS_TARGET'] == 'Android':
- SOURCES += [
- 'ifaddrs_android.cpp',
- ]
-
Library('nksctp_s')
include('/ipc/chromium/chromium-config.mozbuild')
@@ -58,16 +53,11 @@ for var in ('SCTP_SIMPLE_ALLOCATOR',
'CALLBACK_API', 'SCTP_DEBUG'):
DEFINES[var] = 1
-# Android NDK r5c, used on the builders at the time of this writing, doesn't
-# have the headers we need for IPv6
-if CONFIG['OS_TARGET'] != 'Android':
- DEFINES['INET6'] = 1
+DEFINES['INET6'] = 1
if CONFIG['OS_TARGET'] == 'WINNT':
DEFINES['__Userspace_os_Windows'] = 1
DEFINES['_LIB'] = 1
-elif CONFIG['OS_TARGET'] == 'Android':
- DEFINES['__Userspace_os_Linux'] = 1
else:
DEFINES['__Userspace_os_%s' % CONFIG['OS_TARGET']] = 1
@@ -75,7 +65,7 @@ if CONFIG['OS_TARGET'] == 'Darwin':
DEFINES['__APPLE_USE_RFC_2292'] = 1
DEFINES['__APPLE__'] = False
-if CONFIG['OS_TARGET'] in ('Linux', 'Android'):
+if CONFIG['OS_TARGET'] == 'Linux':
# to make sure that in6_pktinfo gets defined on all distros
DEFINES['_GNU_SOURCE'] = True
diff --git a/netwerk/sctp/src/netinet/sctp.h b/netwerk/sctp/src/netinet/sctp.h
index a5ff4eb0b..962ce1140 100755
--- a/netwerk/sctp/src/netinet/sctp.h
+++ b/netwerk/sctp/src/netinet/sctp.h
@@ -32,7 +32,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 279859 2015-03-10 19:49:25Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356270 2020-01-02 13:55:10Z tuexen $");
#endif
#ifndef _NETINET_SCTP_H_
@@ -598,7 +598,10 @@ struct sctp_error_no_user_data {
#define SCTP_MOBILITY_PRIM_DELETED 0x00000004
-#define SCTP_SMALLEST_PMTU 512 /* smallest pmtu allowed when disabling PMTU discovery */
+/* Smallest PMTU allowed when disabling PMTU discovery */
+#define SCTP_SMALLEST_PMTU 512
+/* Largest PMTU allowed when disabling PMTU discovery */
+#define SCTP_LARGEST_PMTU 65536
#if defined(__Userspace_os_Windows)
#pragma pack()
diff --git a/netwerk/sctp/src/netinet/sctp_auth.c b/netwerk/sctp/src/netinet/sctp_auth.c
index ee5ca36ce..4e9f7e4cd 100755
--- a/netwerk/sctp/src/netinet/sctp_auth.c
+++ b/netwerk/sctp/src/netinet/sctp_auth.c
@@ -32,7 +32,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 271673 2014-09-16 14:20:33Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 355931 2019-12-20 15:25:08Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -1450,7 +1450,8 @@ sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m,
ptype = ntohs(phdr->param_type);
plen = ntohs(phdr->param_length);
- if ((plen == 0) || (offset + plen > length))
+ if ((plen < sizeof(struct sctp_paramhdr)) ||
+ (offset + plen > length))
break;
if (ptype == SCTP_RANDOM) {
diff --git a/netwerk/sctp/src/netinet/sctp_bsd_addr.c b/netwerk/sctp/src/netinet/sctp_bsd_addr.c
index 292941b53..f79b9ebb1 100755
--- a/netwerk/sctp/src/netinet/sctp_bsd_addr.c
+++ b/netwerk/sctp/src/netinet/sctp_bsd_addr.c
@@ -48,14 +48,10 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 276914 2015-01-10 20:49:57Z
#include <netinet/sctp_asconf.h>
#include <netinet/sctp_sysctl.h>
#include <netinet/sctp_indata.h>
-#if defined(ANDROID)
-#include <unistd.h>
-#include <ifaddrs-android-ext.h>
-#else
+
#if defined(__FreeBSD__)
#include <sys/unistd.h>
#endif
-#endif
/* Declare all of our malloc named types */
#ifndef __Panda__
diff --git a/netwerk/sctp/src/netinet/sctp_os_userspace.h b/netwerk/sctp/src/netinet/sctp_os_userspace.h
index bf4a3b519..13df42423 100755
--- a/netwerk/sctp/src/netinet/sctp_os_userspace.h
+++ b/netwerk/sctp/src/netinet/sctp_os_userspace.h
@@ -495,7 +495,7 @@ struct sx {int dummy;};
/* for getifaddrs */
#include <sys/types.h>
#if !defined(__Userspace_os_Windows)
-#if !defined(ANDROID) && (defined(INET) || defined(INET6))
+#if defined(INET) || defined(INET6)
#include <ifaddrs.h>
#endif
diff --git a/netwerk/sctp/src/netinet/sctp_pcb.c b/netwerk/sctp/src/netinet/sctp_pcb.c
index 58c164f50..ea5725c85 100755
--- a/netwerk/sctp/src/netinet/sctp_pcb.c
+++ b/netwerk/sctp/src/netinet/sctp_pcb.c
@@ -32,7 +32,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 280459 2015-03-24 21:12:45Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 355931 2019-12-20 15:25:08Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -7213,7 +7213,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
if (offset + plen > limit) {
break;
}
- if (plen == 0) {
+ if (plen < sizeof(struct sctp_paramhdr)) {
break;
}
#ifdef INET
@@ -7413,6 +7413,9 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
if (plen > sizeof(lstore)) {
return (-23);
}
+ if (plen < sizeof(struct sctp_asconf_addrv4_param)) {
+ return (-101);
+ }
phdr = sctp_get_next_param(m, offset,
(struct sctp_paramhdr *)&lstore,
min(plen,sizeof(lstore)));
diff --git a/netwerk/sctp/src/netinet/sctp_usrreq.c b/netwerk/sctp/src/netinet/sctp_usrreq.c
index d24a21815..7ffd8e8c8 100755
--- a/netwerk/sctp/src/netinet/sctp_usrreq.c
+++ b/netwerk/sctp/src/netinet/sctp_usrreq.c
@@ -32,7 +32,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 280459 2015-03-24 21:12:45Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 356270 2020-01-02 13:55:10Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -5995,6 +5995,14 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
return (EINVAL);
}
+ if ((paddrp->spp_flags & SPP_PMTUD_DISABLE) &&
+ ((paddrp->spp_pathmtu < SCTP_SMALLEST_PMTU) ||
+ (paddrp->spp_pathmtu > SCTP_LARGEST_PMTU))) {
+ if (stcb)
+ SCTP_TCB_UNLOCK(stcb);
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+ return (EINVAL);
+ }
if (stcb != NULL) {
/************************TCB SPECIFIC SET ******************/
@@ -6038,7 +6046,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SOCKOPT, SCTP_SO_LOCKED);
sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net);
}
- if ((paddrp->spp_flags & SPP_PMTUD_DISABLE) && (paddrp->spp_pathmtu >= SCTP_SMALLEST_PMTU)) {
+ if (paddrp->spp_flags & SPP_PMTUD_DISABLE) {
if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) {
sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net,
SCTP_FROM_SCTP_USRREQ+SCTP_LOC_10);
@@ -6160,7 +6168,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
sctp_stcb_feature_on(inp, stcb, SCTP_PCB_FLAGS_DONOT_HEARTBEAT);
}
- if ((paddrp->spp_flags & SPP_PMTUD_DISABLE) && (paddrp->spp_pathmtu >= SCTP_SMALLEST_PMTU)) {
+ if (paddrp->spp_flags & SPP_PMTUD_DISABLE) {
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) {
sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net,