diff options
Diffstat (limited to 'lib/libc/net')
-rw-r--r-- | lib/libc/net/Symbol.map | 1 | ||||
-rw-r--r-- | lib/libc/net/base64.c | 27 | ||||
-rw-r--r-- | lib/libc/net/eui64.c | 1 | ||||
-rw-r--r-- | lib/libc/net/getaddrinfo.3 | 4 | ||||
-rw-r--r-- | lib/libc/net/getaddrinfo.c | 1 | ||||
-rw-r--r-- | lib/libc/net/getifaddrs.3 | 22 | ||||
-rw-r--r-- | lib/libc/net/ip6opt.c | 2 | ||||
-rw-r--r-- | lib/libc/net/name6.c | 1 | ||||
-rw-r--r-- | lib/libc/net/nsdispatch.c | 25 | ||||
-rw-r--r-- | lib/libc/net/recv.c | 6 | ||||
-rw-r--r-- | lib/libc/net/sctp_recvmsg.3 | 10 | ||||
-rw-r--r-- | lib/libc/net/sctp_send.3 | 2 | ||||
-rw-r--r-- | lib/libc/net/sctp_sys_calls.c | 10 | ||||
-rw-r--r-- | lib/libc/net/send.c | 6 |
14 files changed, 71 insertions, 47 deletions
diff --git a/lib/libc/net/Symbol.map b/lib/libc/net/Symbol.map index 2eddc47..01d3bcb 100644 --- a/lib/libc/net/Symbol.map +++ b/lib/libc/net/Symbol.map @@ -124,6 +124,7 @@ FBSD_1.0 { in6addr_nodelocal_allnodes; in6addr_linklocal_allnodes; sctp_getaddrlen; + sctp_getassocid; sctp_bindx; sctp_connectx; sctp_peeloff; diff --git a/lib/libc/net/base64.c b/lib/libc/net/base64.c index 4335030..8a9c59e 100644 --- a/lib/libc/net/base64.c +++ b/lib/libc/net/base64.c @@ -193,12 +193,10 @@ b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) { */ int -b64_pton(src, target, targsize) - char const *src; - u_char *target; - size_t targsize; +b64_pton(const char *src, u_char *target, size_t targsize) { int tarindex, state, ch; + u_char nextbyte; char *pos; state = 0; @@ -226,22 +224,28 @@ b64_pton(src, target, targsize) break; case 1: if (target) { - if ((size_t)tarindex + 1 >= targsize) + if ((size_t)tarindex >= targsize) return (-1); target[tarindex] |= (pos - Base64) >> 4; - target[tarindex+1] = ((pos - Base64) & 0x0f) - << 4 ; + nextbyte = ((pos - Base64) & 0x0f) << 4; + if ((size_t)tarindex + 1 < targsize) + target[tarindex + 1] = nextbyte; + else if (nextbyte) + return (-1); } tarindex++; state = 2; break; case 2: if (target) { - if ((size_t)tarindex + 1 >= targsize) + if ((size_t)tarindex >= targsize) return (-1); target[tarindex] |= (pos - Base64) >> 2; - target[tarindex+1] = ((pos - Base64) & 0x03) - << 6; + nextbyte = ((pos - Base64) & 0x03) << 6; + if ((size_t)tarindex + 1 < targsize) + target[tarindex + 1] = nextbyte; + else if (nextbyte) + return (-1); } tarindex++; state = 3; @@ -299,7 +303,8 @@ b64_pton(src, target, targsize) * zeros. If we don't check them, they become a * subliminal channel. */ - if (target && target[tarindex] != 0) + if (target && (size_t)tarindex < targsize && + target[tarindex] != 0) return (-1); } } else { diff --git a/lib/libc/net/eui64.c b/lib/libc/net/eui64.c index d9ed76c..bb3077f 100644 --- a/lib/libc/net/eui64.c +++ b/lib/libc/net/eui64.c @@ -132,6 +132,7 @@ eui64_line(const char *l, struct eui64 *e, char *hostname, size_t len) goto bad; } + free(linehead); return (0); bad: diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3 index 5d03aab..570fc2e 100644 --- a/lib/libc/net/getaddrinfo.3 +++ b/lib/libc/net/getaddrinfo.3 @@ -237,8 +237,8 @@ pointer in each .Li addrinfo structure until a null pointer is encountered. The three members -.Fa ai_family, -.Fa ai_socktype, +.Fa ai_family , +.Fa ai_socktype , and .Fa ai_protocol in each returned diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index c50374e..17c9b65 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$"); #include <ifaddrs.h> #include <sys/queue.h> #ifdef INET6 -#include <net/if_var.h> #include <sys/sysctl.h> #include <sys/ioctl.h> #include <netinet6/in6_var.h> diff --git a/lib/libc/net/getifaddrs.3 b/lib/libc/net/getifaddrs.3 index ff3f774..b0b17bb 100644 --- a/lib/libc/net/getifaddrs.3 +++ b/lib/libc/net/getifaddrs.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 21, 2013 +.Dd November 25, 2014 .Dt GETIFADDRS 3 .Os .Sh NAME @@ -110,19 +110,17 @@ if one exists, otherwise it is NULL. .Pp The .Li ifa_data -field references address family specific data. -For -.Dv AF_LINK -addresses it contains a pointer to the +field references address family specific data +in a pointer to the .Fa struct if_data (as defined in include file -.In net/if.h ) -which contains various interface attributes and statistics. -For all other address families, it contains a pointer to the -.Fa struct ifa_data -(as defined in include file -.In net/if.h ) -which contains per-address interface statistics. +.In net/if.h ) . +For +.Dv AF_LINK +addresses, +it contains various interface attributes and statistics. +For all other address families, +it contains per-address interface statistics. .Pp The data returned by .Fn getifaddrs diff --git a/lib/libc/net/ip6opt.c b/lib/libc/net/ip6opt.c index a467758..2f0c51d 100644 --- a/lib/libc/net/ip6opt.c +++ b/lib/libc/net/ip6opt.c @@ -419,7 +419,7 @@ inet6_opt_append(void *extbuf, socklen_t extlen, int offset, u_int8_t type, * The option data length must have a value between 0 and 255, * inclusive, and is the length of the option data that follows. */ - if (len < 0 || len > 255) + if (len > 255 || len < 0 ) return(-1); /* diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index 97880a2..89effe6 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -94,7 +94,6 @@ __FBSDID("$FreeBSD$"); #include <netinet/in.h> #ifdef INET6 #include <net/if.h> -#include <net/if_var.h> #include <sys/sysctl.h> #include <sys/ioctl.h> #include <netinet6/in6_var.h> /* XXX */ diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c index c23315c..4de1df3 100644 --- a/lib/libc/net/nsdispatch.c +++ b/lib/libc/net/nsdispatch.c @@ -132,14 +132,17 @@ static void *nss_cache_cycle_prevention_func = NULL; #endif /* - * When this is set to 1, nsdispatch won't use nsswitch.conf - * but will consult the 'defaults' source list only. - * NOTE: nested fallbacks (when nsdispatch calls fallback functions, - * which in turn calls nsdispatch, which should call fallback - * function) are not supported + * We keep track of nsdispatch() nesting depth in dispatch_depth. When a + * fallback method is invoked from nsdispatch(), we temporarily set + * fallback_depth to the current dispatch depth plus one. Subsequent + * calls at that exact depth will run in fallback mode (restricted to the + * same source as the call that was handled by the fallback method), while + * calls below that depth will be handled normally, allowing fallback + * methods to perform arbitrary lookups. */ struct fb_state { - int fb_dispatch; + int dispatch_depth; + int fallback_depth; }; static void fb_endstate(void *); NSS_TLS_HANDLING(fb); @@ -613,6 +616,7 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, void *mdata; int isthreaded, serrno, i, result, srclistsize; struct fb_state *st; + int saved_depth; #ifdef NS_CACHING nss_cache_data cache_data; @@ -644,7 +648,8 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, result = NS_UNAVAIL; goto fin; } - if (st->fb_dispatch == 0) { + ++st->dispatch_depth; + if (st->dispatch_depth > st->fallback_depth) { dbt = vector_search(&database, _nsmap, _nsmapsize, sizeof(*_nsmap), string_compare); fb_method = nss_method_lookup(NSSRC_FALLBACK, database, @@ -713,12 +718,13 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, break; } else { if (fb_method != NULL) { - st->fb_dispatch = 1; + saved_depth = st->fallback_depth; + st->fallback_depth = st->dispatch_depth + 1; va_start(ap, defaults); result = fb_method(retval, (void *)srclist[i].name, ap); va_end(ap); - st->fb_dispatch = 0; + st->fallback_depth = saved_depth; } else nss_log(LOG_DEBUG, "%s, %s, %s, not found, " "and no fallback provided", @@ -750,6 +756,7 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, if (isthreaded) (void)_pthread_rwlock_unlock(&nss_lock); + --st->dispatch_depth; fin: errno = serrno; return (result); diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c index f71d478..6a584ca 100644 --- a/lib/libc/net/recv.c +++ b/lib/libc/net/recv.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/socket.h> +#include "libc_private.h" #include <stddef.h> @@ -48,5 +49,8 @@ recv(s, buf, len, flags) * POSIX says recv() shall be a cancellation point, so call the * cancellation-enabled recvfrom() and not _recvfrom(). */ - return (recvfrom(s, buf, len, flags, NULL, 0)); + return (((ssize_t (*)(int, void *, size_t, int, + struct sockaddr *, socklen_t *)) + __libc_interposing[INTERPOS_recvfrom])(s, buf, len, flags, + NULL, NULL)); } diff --git a/lib/libc/net/sctp_recvmsg.3 b/lib/libc/net/sctp_recvmsg.3 index e3ced9c..945797d 100644 --- a/lib/libc/net/sctp_recvmsg.3 +++ b/lib/libc/net/sctp_recvmsg.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 13, 2007 +.Dd April 23, 2015 .Dt SCTP_RECVMSG 3 .Os .Sh NAME @@ -98,13 +98,13 @@ receive buffer, then the argument will .Em not have the -.Dv MSG_EOF +.Dv MSG_EOR flag applied. If the message is a complete message then the .Fa flags argument will have -.Dv MSG_EOF +.Dv MSG_EOR set. Locally detected errors are indicated by a return value of -1 with @@ -282,12 +282,12 @@ This typically means that the socket is not connected and is a one-to-one style socket. .El .Sh SEE ALSO +.Xr getsockopt 2 , .Xr recv 2 , .Xr select 2 , +.Xr setsockopt 2 , .Xr socket 2 , .Xr write 2 , -.Xr getsockopt 2 , -.Xr setsockopt 2 , .Xr sctp_send 3 , .Xr sctp_sendmsg 3 , .Xr sendmsg 3 , diff --git a/lib/libc/net/sctp_send.3 b/lib/libc/net/sctp_send.3 index 37b0b71..9c7f833 100644 --- a/lib/libc/net/sctp_send.3 +++ b/lib/libc/net/sctp_send.3 @@ -337,7 +337,7 @@ is not connected and is a one-to-one style socket. .Xr select 2 , .Xr sendmsg 2 , .Xr socket 2 , -.Xr write 2 +.Xr write 2 , .Xr sctp_connectx 3 , .Xr sctp_recvmsg 3 , .Xr sctp_sendmsg 3 , diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index 91527c3..f07aa43 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -383,6 +383,9 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size) case SCTP_PR_ASSOC_STATUS: ((struct sctp_prstatus *)arg)->sprstat_assoc_id = id; break; + case SCTP_MAX_CWND: + ((struct sctp_assoc_value *)arg)->assoc_id = id; + break; default: break; } @@ -597,6 +600,7 @@ sctp_sendmsg(int s, msg.msg_iovlen = 1; msg.msg_control = cmsgbuf; msg.msg_controllen = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)); + msg.msg_flags = 0; cmsg = (struct cmsghdr *)cmsgbuf; cmsg->cmsg_level = IPPROTO_SCTP; cmsg->cmsg_type = SCTP_SNDRCV; @@ -663,6 +667,7 @@ sctp_send(int sd, const void *data, size_t len, msg.msg_iovlen = 1; msg.msg_control = cmsgbuf; msg.msg_controllen = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)); + msg.msg_flags = 0; cmsg = (struct cmsghdr *)cmsgbuf; cmsg->cmsg_level = IPPROTO_SCTP; cmsg->cmsg_type = SCTP_SNDRCV; @@ -820,7 +825,6 @@ sctp_recvmsg(int s, errno = EINVAL; return (-1); } - msg.msg_flags = 0; iov.iov_base = dbuf; iov.iov_len = len; msg.msg_name = (caddr_t)from; @@ -832,6 +836,7 @@ sctp_recvmsg(int s, msg.msg_iovlen = 1; msg.msg_control = cmsgbuf; msg.msg_controllen = sizeof(cmsgbuf); + msg.msg_flags = 0; sz = recvmsg(s, &msg, *msg_flags); *msg_flags = msg.msg_flags; if (sz <= 0) { @@ -886,7 +891,7 @@ sctp_recvv(int sd, struct sctp_rcvinfo *rcvinfo; struct sctp_nxtinfo *nxtinfo; - if (((info != NULL) && (infolen == NULL)) | + if (((info != NULL) && (infolen == NULL)) || ((info == NULL) && (infolen != NULL) && (*infolen != 0)) || ((info != NULL) && (infotype == NULL))) { errno = EINVAL; @@ -905,6 +910,7 @@ sctp_recvv(int sd, msg.msg_iovlen = iovlen; msg.msg_control = cmsgbuf; msg.msg_controllen = sizeof(cmsgbuf); + msg.msg_flags = 0; ret = recvmsg(sd, &msg, *flags); *flags = msg.msg_flags; if ((ret > 0) && diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c index 93cdfda..c44f4b9 100644 --- a/lib/libc/net/send.c +++ b/lib/libc/net/send.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/socket.h> +#include "libc_private.h" #include <stddef.h> @@ -48,5 +49,8 @@ send(s, msg, len, flags) * POSIX says send() shall be a cancellation point, so call the * cancellation-enabled sendto() and not _sendto(). */ - return (sendto(s, msg, len, flags, NULL, 0)); + return (((ssize_t (*)(int, const void *, size_t, int, + const struct sockaddr *, socklen_t)) + __libc_interposing[INTERPOS_sendto])(s, msg, len, flags, + NULL, 0)); } |