Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/libevent merge and update manpages and include/...
details: https://anonhg.NetBSD.org/src/rev/5c2fa6f581d1
branches: trunk
changeset: 335898:5c2fa6f581d1
user: spz <spz%NetBSD.org@localhost>
date: Thu Jan 29 07:26:02 2015 +0000
description:
merge and update manpages and include/event2/event-config.h
May need extra fixing around log-internal.h and log.c
diffstat:
external/bsd/libevent/dist/buffer.c | 90 +++++++++-
external/bsd/libevent/dist/bufferevent.c | 6 +-
external/bsd/libevent/dist/evbuffer-internal.h | 16 +-
external/bsd/libevent/dist/evdns.c | 52 ++++-
external/bsd/libevent/dist/event.c | 26 ++-
external/bsd/libevent/dist/event_tagging.c | 10 +-
external/bsd/libevent/dist/evrpc.c | 44 ++--
external/bsd/libevent/dist/evutil.c | 20 +-
external/bsd/libevent/dist/evutil_rand.c | 35 +++-
external/bsd/libevent/dist/http.c | 15 +-
external/bsd/libevent/dist/include/event2/rpc.h | 2 +-
external/bsd/libevent/dist/include/event2/util.h | 75 ++++++--
external/bsd/libevent/dist/log-internal.h | 6 +-
external/bsd/libevent/dist/log.c | 6 +-
external/bsd/libevent/dist/ltmain.sh | 2 +-
external/bsd/libevent/dist/test/regress.c | 6 +-
external/bsd/libevent/dist/test/regress.h | 4 +-
external/bsd/libevent/dist/test/regress_buffer.c | 8 +-
external/bsd/libevent/dist/test/regress_http.c | 22 +-
external/bsd/libevent/dist/util-internal.h | 6 +-
external/bsd/libevent/include/event2/event-config.h | 32 +-
external/bsd/libevent/libevent2netbsd | 7 +-
external/bsd/libevent/man/buffer.h.3 | 123 +++++++++-----
external/bsd/libevent/man/buffer_compat.h.3 | 10 +-
external/bsd/libevent/man/bufferevent.3 | 6 +-
external/bsd/libevent/man/bufferevent_ssl.h.3 | 16 +-
external/bsd/libevent/man/deprecated.3 | 9 +-
external/bsd/libevent/man/dns.h.3 | 89 ++++++----
external/bsd/libevent/man/dns_compat.h.3 | 62 ++++--
external/bsd/libevent/man/evbuffer_cb_info.3 | 6 +-
external/bsd/libevent/man/evbuffer_iovec.3 | 4 +-
external/bsd/libevent/man/evbuffer_ptr.3 | 2 +-
external/bsd/libevent/man/event.h.3 | 119 ++++++++------
external/bsd/libevent/man/event_base.3 | 4 +-
external/bsd/libevent/man/event_compat.h.3 | 40 +++-
external/bsd/libevent/man/event_config.3 | 4 +-
external/bsd/libevent/man/evthread_condition_callbacks.3 | 2 +-
external/bsd/libevent/man/evthread_lock_callbacks.3 | 2 +-
external/bsd/libevent/man/evutil_addrinfo.3 | 2 +-
external/bsd/libevent/man/http.h.3 | 110 ++++++++-----
external/bsd/libevent/man/http_compat.h.3 | 14 +-
external/bsd/libevent/man/rpc.h.3 | 88 ++++++---
external/bsd/libevent/man/rpc_compat.h.3 | 2 +-
external/bsd/libevent/man/tag.h.3 | 6 +-
external/bsd/libevent/man/tag_compat.h.3 | 4 +-
external/bsd/libevent/man/thread.h.3 | 10 +-
external/bsd/libevent/man/util.h.3 | 34 +++-
47 files changed, 822 insertions(+), 436 deletions(-)
diffs (truncated from 3950 to 300 lines):
diff -r 4cae79ffa9b1 -r 5c2fa6f581d1 external/bsd/libevent/dist/buffer.c
--- a/external/bsd/libevent/dist/buffer.c Thu Jan 29 06:53:28 2015 +0000
+++ b/external/bsd/libevent/dist/buffer.c Thu Jan 29 07:26:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: buffer.c,v 1.2 2013/04/11 16:56:41 christos Exp $ */
+/* $NetBSD: buffer.c,v 1.3 2015/01/29 07:26:02 spz Exp $ */
/*
* Copyright (c) 2002-2007 Niels Provos <provos%citi.umich.edu@localhost>
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
@@ -28,7 +28,7 @@
#include "event2/event-config.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: buffer.c,v 1.2 2013/04/11 16:56:41 christos Exp $");
+__RCSID("$NetBSD: buffer.c,v 1.3 2015/01/29 07:26:02 spz Exp $");
#ifdef WIN32
#include <winsock2.h>
@@ -88,7 +88,7 @@
#include "event2/thread.h"
#include "event2/event-config.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: buffer.c,v 1.2 2013/04/11 16:56:41 christos Exp $");
+__RCSID("$NetBSD: buffer.c,v 1.3 2015/01/29 07:26:02 spz Exp $");
#include "log-internal.h"
#include "mm-internal.h"
#include "util-internal.h"
@@ -162,12 +162,20 @@
struct evbuffer_chain *chain;
size_t to_alloc;
+ if (size > EVBUFFER_CHAIN_MAX - EVBUFFER_CHAIN_SIZE)
+ return (NULL);
+
size += EVBUFFER_CHAIN_SIZE;
/* get the next largest memory that can hold the buffer */
- to_alloc = MIN_BUFFER_SIZE;
- while (to_alloc < size)
- to_alloc <<= 1;
+ if (size < EVBUFFER_CHAIN_MAX / 2) {
+ to_alloc = MIN_BUFFER_SIZE;
+ while (to_alloc < size) {
+ to_alloc <<= 1;
+ }
+ } else {
+ to_alloc = size;
+ }
/* we get everything in one chunk */
if ((chain = mm_malloc(to_alloc)) == NULL)
@@ -1007,6 +1015,7 @@
buf->first = chain;
if (chain) {
+ EVUTIL_ASSERT(remaining <= chain->off);
chain->misalign += remaining;
chain->off -= remaining;
}
@@ -1073,6 +1082,7 @@
if (datlen) {
EVUTIL_ASSERT(chain);
+ EVUTIL_ASSERT(datlen <= chain->off);
memcpy(data, chain->buffer + chain->misalign, datlen);
}
@@ -1548,6 +1558,10 @@
if (buf->freeze_end) {
goto done;
}
+ /* Prevent buf->total_len overflow */
+ if (datlen > EV_SIZE_MAX - buf->total_len) {
+ goto done;
+ }
chain = buf->last;
@@ -1561,7 +1575,10 @@
}
if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) {
- remain = (size_t)(chain->buffer_len - chain->misalign - chain->off);
+ /* Always true for mutable buffers */
+ EVUTIL_ASSERT(chain->misalign >= 0 &&
+ (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX);
+ remain = chain->buffer_len - (size_t)chain->misalign - chain->off;
if (remain >= datlen) {
/* there's enough space to hold all the data in the
* current last chain */
@@ -1632,6 +1649,9 @@
if (buf->freeze_start) {
goto done;
}
+ if (datlen > EV_SIZE_MAX - buf->total_len) {
+ goto done;
+ }
chain = buf->first;
@@ -1644,6 +1664,10 @@
/* we cannot touch immutable buffers */
if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) {
+ /* Always true for mutable buffers */
+ EVUTIL_ASSERT(chain->misalign >= 0 &&
+ (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX);
+
/* If this chain is empty, we can treat it as
* 'empty at the beginning' rather than 'empty at the end' */
if (chain->off == 0)
@@ -1681,6 +1705,7 @@
tmp->next = chain;
tmp->off = datlen;
+ EVUTIL_ASSERT(datlen <= tmp->buffer_len);
tmp->misalign = tmp->buffer_len - datlen;
memcpy(tmp->buffer + tmp->misalign, data, datlen);
@@ -1779,7 +1804,9 @@
/* Would expanding this chunk be affordable and worthwhile? */
if (CHAIN_SPACE_LEN(chain) < chain->buffer_len / 8 ||
- chain->off > MAX_TO_COPY_IN_EXPAND) {
+ chain->off > MAX_TO_COPY_IN_EXPAND ||
+ (datlen < EVBUFFER_CHAIN_MAX &&
+ EVBUFFER_CHAIN_MAX - datlen >= chain->off)) {
/* It's not worth resizing this chain. Can the next one be
* used? */
if (chain->next && CHAIN_SPACE_LEN(chain->next) >= datlen) {
@@ -1907,6 +1934,8 @@
rmv_all = 1;
avail = 0;
} else {
+ /* can't overflow, since only mutable chains have
+ * huge misaligns. */
avail = (size_t) CHAIN_SPACE_LEN(chain);
chain = chain->next;
}
@@ -1917,6 +1946,7 @@
EVUTIL_ASSERT(chain->off == 0);
evbuffer_chain_free(chain);
}
+ EVUTIL_ASSERT(datlen >= avail);
tmp = evbuffer_chain_new(datlen - avail);
if (tmp == NULL) {
if (rmv_all) {
@@ -2046,6 +2076,7 @@
unsigned long lng = EVBUFFER_MAX_READ;
if (ioctlsocket(fd, FIONREAD, &lng) < 0)
return -1;
+ /* Can overflow, but mostly harmlessly. XXXX */
return (int)lng;
#elif defined(FIONREAD)
int n = EVBUFFER_MAX_READ;
@@ -2158,8 +2189,14 @@
#ifdef USE_IOVEC_IMPL
remaining = n;
for (i=0; i < nvecs; ++i) {
- ev_ssize_t space = (ev_ssize_t) CHAIN_SPACE_LEN(*chainp);
- if (space < remaining) {
+ /* can't overflow, since only mutable chains have
+ * huge misaligns. */
+ size_t space = (size_t) CHAIN_SPACE_LEN(*chainp);
+ /* XXXX This is a kludge that can waste space in perverse
+ * situations. */
+ if (space > EVBUFFER_CHAIN_MAX)
+ space = EVBUFFER_CHAIN_MAX;
+ if ((ev_ssize_t)space < remaining) {
(*chainp)->off += space;
remaining -= (int)space;
} else {
@@ -2368,9 +2405,11 @@
/* XXX(nickm) Don't disable this code until we know if
* the WSARecv code above works. */
void *p = evbuffer_pullup(buffer, howmuch);
+ EVUTIL_ASSERT(p || !howmuch);
n = send(fd, p, howmuch, 0);
#else
void *p = evbuffer_pullup(buffer, howmuch);
+ EVUTIL_ASSERT(p || !howmuch);
n = write(fd, p, howmuch);
#endif
#ifdef USE_SENDFILE
@@ -2430,12 +2469,17 @@
case EVBUFFER_PTR_ADD:
/* this avoids iterating over all previous chains if
we just want to advance the position */
+ if (pos->pos < 0 || EV_SIZE_MAX - position < (size_t)pos->pos) {
+ EVBUFFER_UNLOCK(buf);
+ return -1;
+ }
chain = pos->_internal.chain;
pos->pos += position;
position = pos->_internal.pos_in_chain;
break;
}
+ EVUTIL_ASSERT(EV_SIZE_MAX - left >= position);
while (chain && position + left >= chain->off) {
left -= chain->off - position;
chain = chain->next;
@@ -2468,7 +2512,9 @@
ASSERT_EVBUFFER_LOCKED(buf);
- if (pos->pos + len > buf->total_len)
+ if (pos->pos < 0 ||
+ EV_SIZE_MAX - len < (size_t)pos->pos ||
+ pos->pos + len > buf->total_len)
return -1;
chain = pos->_internal.chain;
@@ -2592,7 +2638,10 @@
if (n_vec == 0 && len < 0) {
/* If no vectors are provided and they asked for "everything",
* pretend they asked for the actual available amount. */
- len = buffer->total_len - len_so_far;
+ len = buffer->total_len;
+ if (start_at) {
+ len -= start_at->pos;
+ }
}
while (chain) {
@@ -2656,6 +2705,9 @@
if (sz < 0)
goto done;
+ if (INT_MAX >= EVBUFFER_CHAIN_MAX &&
+ (size_t)sz >= EVBUFFER_CHAIN_MAX)
+ goto done;
if ((size_t)sz < space) {
chain->off += sz;
buf->total_len += sz;
@@ -2749,6 +2801,11 @@
#endif
int ok = 1;
+ if (offset < 0 || length < 0 ||
+ ((ev_uint64_t)length > EVBUFFER_CHAIN_MAX) ||
+ (ev_uint64_t)offset > (ev_uint64_t)(EVBUFFER_CHAIN_MAX - length))
+ return (-1);
+
#if defined(USE_SENDFILE)
if (use_sendfile) {
EVBUFFER_LOCK(outbuf);
@@ -2837,7 +2894,7 @@
{
/* the default implementation */
struct evbuffer *tmp = evbuffer_new();
- ev_ssize_t nread;
+ ev_ssize_t read;
if (tmp == NULL)
return (-1);
@@ -2854,13 +2911,14 @@
* can abort without side effects if the read fails.
*/
while (length) {
- nread = evbuffer_readfile(tmp, fd, (ev_ssize_t)length);
- if (nread == -1) {
+ ev_ssize_t to_read = length > EV_SSIZE_MAX ? EV_SSIZE_MAX : (ev_ssize_t)length;
+ read = evbuffer_readfile(tmp, fd, to_read);
+ if (read == -1) {
evbuffer_free(tmp);
return (-1);
}
- length -= nread;
+ length -= read;
}
EVBUFFER_LOCK(outbuf);
diff -r 4cae79ffa9b1 -r 5c2fa6f581d1 external/bsd/libevent/dist/bufferevent.c
--- a/external/bsd/libevent/dist/bufferevent.c Thu Jan 29 06:53:28 2015 +0000
+++ b/external/bsd/libevent/dist/bufferevent.c Thu Jan 29 07:26:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufferevent.c,v 1.2 2013/04/11 16:56:41 christos Exp $ */
+/* $NetBSD: bufferevent.c,v 1.3 2015/01/29 07:26:02 spz Exp $ */
/*
* Copyright (c) 2002-2007 Niels Provos <provos%citi.umich.edu@localhost>
* Copyright (c) 2007-2012 Niels Provos, Nick Mathewson
@@ -30,7 +30,7 @@
#include "event2/event-config.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bufferevent.c,v 1.2 2013/04/11 16:56:41 christos Exp $");
+__RCSID("$NetBSD: bufferevent.c,v 1.3 2015/01/29 07:26:02 spz Exp $");
#ifdef _EVENT_HAVE_SYS_TIME_H
#include <sys/time.h>
@@ -548,7 +548,7 @@
bufev_private->read_watermarks_cb,
EVBUFFER_CB_ENABLED|EVBUFFER_CB_NODEFER);
- if (evbuffer_get_length(bufev->input) > highmark)
+ if (evbuffer_get_length(bufev->input) >= highmark)
bufferevent_wm_suspend_read(bufev);
else if (evbuffer_get_length(bufev->input) < highmark)
Home |
Main Index |
Thread Index |
Old Index