122 Commits

Author SHA1 Message Date
Nick Mathewson
d14bb926b4 Use -Wlogical-op on gcc 4.5 or higher
It exposed one bug for us (see 8c3452bcb294e07888), and might
prevent more.
2010-05-18 14:05:01 -04:00
Nick Mathewson
75701e897b Add some missing includes to fix Linux build again 2010-05-14 14:30:09 -04:00
Nick Mathewson
9cb5bc86a9 Bump version to 2.0.5-beta-dev 2010-05-10 14:51:32 -04:00
Nick Mathewson
ad9b7f153d Increment version numbers for 2.0.5-beta 2010-05-09 00:22:08 -04:00
Nick Mathewson
7c519dfd4f Fix some autoconf issues on OpenBSD
Issue 1: autoconf gets accept when a header works properly with cpp
but not with cc.  This was true of the sys/sysctl.h header on
openbsd.  The fix: include sys/param.h (if present) when testing for
sys/sysctl.h

Issue 2: Somehow, autoconf's macro generation code is messed up on
some versions of openbsd (including mine, and other people's too) so
that instead of SIZEOF_VOID_P, it makes SIZEOF_VOID__.
evutil/util.h now works around that.
2010-05-08 23:31:35 -04:00
Nick Mathewson
c1cd32a156 Define _REENTRANT as needed on Solaris, elsewhere
It turns out that _REENTRANT isn't only needed to make certain
functions visible; we also need it to make pthreads work properly
some places (like Solaris, where forgetting _REENTRANT basically
means that all threads are sharing the same errno).  Fortunately,
our ACX_PTHREAD() configure macro already gives us a PTHREAD_CFLAG
variable, so all we have to do is use it.
2010-05-08 22:21:52 -04:00
Nick Mathewson
c44de06c76 Numerous opensolaris compilation fixes
For future note, opensolaris doesn't have sys/sysctl.h, doesn't like
comparing iov_buf to a chain_space_ptr without a cast, and is (predictably)
unforgiving of dumb syntax errors.

Also, we had accidentally broken the devpoll backend test in configure.in
2010-05-08 19:34:09 -04:00
Nick Mathewson
40c301b76c Fix compilation when openssl support is disabled
Previously, we'd fail if OpenSSL was present but openssl support was
disabled.  Now we don't.
2010-04-28 14:56:51 -04:00
Nick Mathewson
a47a4b7e7e Fix a couple of bugs in the BSD sysctl arc4seed logic
Of course, FreeBSD has its own arc4random() implementation, so this should
never actually be needed.  Still, it's good to paint the underside of the
wagon.
2010-04-23 16:08:09 -04:00
Nick Mathewson
71fc3eb08b Seed the RNG using sysctl() as well as /dev/urandom
William Ahern points out that if the user has chrooted, they might not
have a working /dev/urandom.  Linux and many of the BSDs, however,
define a sysctl interface to their kernel random number generators.

This patch takes a belt-and-suspenders approach and tries to do use the
sysctl _and_ the /dev/urandom approach if both are present.  When using
the sysctl approach, it tries to bulletproof itself by checking to make
sure that the buffers are actually set by the sysctl calls.
2010-04-23 15:46:04 -04:00
Trond Norbye
3eb044d0a9 Never test for select() on windows
On 64-bit windows, configure actually _finds_ select when it tests for
it, and due to the ordering of the io implementations in event.c it is
chosen over the win32select implementation.

This modification skips the test for select on win32 (we don't want
that anyway, because Windows has its own), causing my windows box to
get the win32select implementation.

(edited by Nick)
2010-03-23 13:27:10 -04:00
Nick Mathewson
2e898f542b Switch to using AM conditionals in place of AC_LIBOBJ
AC_LIBOBJ is really only meant for defining missing library functions,
not conditional code compilation.  Sticking our conditionally compiled
modules in SYS_SRC should make stuff easier to maintain.
2010-03-12 14:16:30 -05:00
Nick Mathewson
2cffd6c937 Bump version to 2.0.4-alpha-dev 2010-02-28 16:53:42 -05:00
Nick Mathewson
9669ade525 Bump the version to 2.0.4-alpha 2010-02-28 16:44:25 -05:00
Nick Mathewson
ca46d25b01 Merge branch 'arc4random' 2010-02-17 23:02:28 -05:00
Nick Mathewson
63e868e69f Increment the submicro version number.
We've changed a couple of APIs introduced in 2.0.1-alpha, so it
behooves us to give high-needs apps (like Tor) a way to tell we've
done this.

Sensible apps will just say "is it 2.0.3-alpha or 2.0.4-alpha" and
ignore the existence of 2.0.3-alpha-dev, which is just as it should
be.
2010-02-15 16:45:19 -05:00
Nick Mathewson
4ec8fea68e Make RNG work when we have arc4random() but not arc4random_buf() 2010-02-13 00:11:44 -05:00
Nick Mathewson
d4de062efc Add an arc4random implementation for use by evdns
Previously, evdns was at the mercy of the user for providing a good
entropy source; without one, it would be vulnerable to various
active attacks.

This patch adds a port of OpenBSD's arc4random() calls to Libevent
[port by Chris Davis], and wraps it up a little bit so we can use it
more safely.
2010-02-11 12:53:32 -05:00
Nick Mathewson
1fa4c81c71 Add ev_[u]intptr_t to include/event2/util.h
We already emulate most of the other useful bits of stdint.h, and
we seem to have started to use uintptr_t in a few places throughout
the code.  Let's make sure we can continue to do so even on backwards
platforms that don't do C99.
2010-01-26 12:06:41 -05:00
Nick Mathewson
cd17c3acd5 Add support for a "debug mode" to try to catch common errors.
Right now it only catches cases where we aren't initializing events,
or where we are re-initializing events without deleting them first.
These are however shockingly common.
2010-01-25 13:53:13 -05:00
Nick Mathewson
7296971b10 Detect setenv/unsetenv; skip main/base_environ test if we can't fake them.
Previously, we assumed that we would have setenv/unsetenv everywhere
but WIN32, where we could fake them with putenv.  This isn't so: some
other non-windows systems lack setenv/unsetenv, and some of them lack
putenv too.

The first part of the solution, then, is to detect setenv/unsetenv/
putenv from configure.in, and to fake setenv/unsetenv with putenv
whenever we have the latter but not one of the former.

But what should we do when we don't even have putenv?  We could do
elaborate tricks to manipulate the environ pointer, but since we're
only doing this for the unit tests, let's just skip the one test in
question that uses setenv/unsetenv.
2010-01-22 15:03:01 -05:00
Nick Mathewson
78ed097267 Never believe that we have pthreads on win32, even if gcc thinks we do.
Apparently some newer versions of mingw provide a fake pthreads api to
let applications work even if they don't know about windows threading.
That's nice, but we aren't one of those.
2009-12-30 13:30:20 -05:00
Nick Mathewson
5a112d3c07 Set all instances of the version number correctly.
Note that we've made two subtle mistakes: we are supposed to suffix
any non-released version with "-dev", and we're supposed to use the
last byte of the numeric version to indicate whether we have done this.

For example, when 2.0.4-alpha is released, its numeric versin will be
0x 02 00 04 00.  As soon as we tag it, we will change the version in
the git repository to 2.0.4-alpha-dev, whose numeric version will be
0x 02 00 04 01 or something.
2009-12-18 23:37:50 -05:00
Niels Provos
505040a2b5 call it 2.0.3-alpha
svn:r1556
2009-11-20 00:18:35 +00:00
Nick Mathewson
888007f9a4 Windows *does* have getservbyname, no matter what autoconf says.
TODO: figure out why autoconf is confused about this.

svn:r1538
2009-11-17 02:38:19 +00:00
Nick Mathewson
86f5742015 Add two implementations of getaddrinfo: one blocking and one nonblocking.
The entry points are evutil_getaddrinfo and evdns_getaddrinfo respectively.
There are fairly extensive unit tests.

I believe this code conforms to RFC3493 pretty closely, but there are
probably more issues.  It should get tested on more platforms.

This code means we can dump the well-intentioned but weirdly-implemented
bufferevent_evdns and evutil_resolve code.

svn:r1537
2009-11-16 22:25:46 +00:00
Nick Mathewson
629a613398 When running set[ug]id, don't check the environment.
Idea from OpenBSD, but made a bit more generic to handle uncivilized lands
that do not define issetugid.

svn:r1530
2009-11-15 18:59:59 +00:00
Nick Mathewson
e2b2de79bf Use arc4random() for dns transaction ids where available. Patch taken from OpenBSD
svn:r1528
2009-11-15 18:59:48 +00:00
Nick Mathewson
47bad8abb7 Implement size limits on HTTP header length and body length.
Patch from Constantine Verutin, simplified a little.

svn:r1500
2009-11-04 20:17:32 +00:00
Nick Mathewson
0b9eb1bffb Add a bufferevent function to resolve a name then connect to it.
This function, bufferevent_socket_connect_hostname() can either use
evdns to do the resolve, or use a new function (evutil_resolve) that
uses getaddrinfo or gethostbyname, like http.c does now.

This function is meant to eventually replace the hostname resolution mess in
http.c.

svn:r1496
2009-11-03 20:40:48 +00:00
Nick Mathewson
18fe400805 Forward-port: fix android compilation
svn:r1435
2009-09-23 23:51:26 +00:00
Nick Mathewson
22bd5b4287 Support sendfile on solaris: patch from Caitlin Mercer.
svn:r1419
2009-08-16 16:40:42 +00:00
Nick Mathewson
709c21c48c Bufferevent support for openssl.
This code adds a new Bufferevent type that is only compiled when the
openssl library is present.  It supports using an SSL object and an
event alert mechanism, which can either be an fd or an underlying
bufferevent.

There is still more work to do: the unit tests are incomplete, and we
need to support flush and shutdown much better.  Sometimes events are
generated needlessly: this will hose performance.

There's a new encrypting proxy in sample/le-proxy.c.

This code has only been tested on OSX, and nowhere else.

svn:r1382
2009-07-28 04:03:57 +00:00
Niels Provos
6fbeb9237c call it 2.0.2-alpha
svn:r1378
2009-07-25 03:23:46 +00:00
Nick Mathewson
1fb2e818a6 Use a uniform strategy when a function is not working: do not expose
it.

Rather than failing at runtime, it is better to fail at compile or
link time.

svn:r1363
2009-07-17 21:47:45 +00:00
Nick Mathewson
d3a8ccb807 Change use of AC_CHECK_LIB to AC_SEARCH_LIBS.
Patch from Zack Weinberg.  His message:

  This one eliminates all use of AC_CHECK_LIB in the configure script.
  AC_CHECK_LIB has a serious flaw: if the library you mention *exists*
  but is not *necessary* for the function you want, it adds it to
  $(LIBS) anyway.  This was fine in the days of static libraries,
  because the linker would ignore an .a library that didn't contain
  anything you needed. However, ELF shared libraries are different
  (let's not get into why): the linker will by default record a
  DT_NEEDED entry for every shared object mentioned on the link
  command line. Thus, every use of AC_CHECK_LIB is a potential
  unnecessary DT_NEEDED, making extra work for the dynamic loader. The
  cure is simply to use AC_SEARCH_LIBS instead; it first tries to find
  the function you ask for in libc, and only if that doesn't work does
  it try to use the extra library you mention.

  For the same reasons, pkg-config .pc files should distinguish
  between the libraries to use for shared linkage (Libs:) and the
  additional libraries needed for static linkage (Libs.private:). I
  have also made that correction in this patch. I also took the
  opportunity to clean up the substitution variables a little and make
  absolutely sure that the core library does not get linked against
  zlib.

svn:r1338
2009-07-10 19:38:16 +00:00
Nick Mathewson
49f18a0aab Add requirement in configure.in for autoconf 2.59c. Needed for ssize_t test. Spotted by Yang Hong.
svn:r1313
2009-05-25 20:02:51 +00:00
Nick Mathewson
b2e8fd0e41 Apparently MSVC lacks a ssize_t. Define an ev_ssize_t for headers, and make ssize_t work elsewhere.
svn:r1261
2009-04-30 23:56:53 +00:00
Nick Mathewson
df0617f289 Use signal.h, not sys/signal.h.
This is patch 2673214 from mmadia.  It is correct, since we unconditionally
include signal.h in many other places, and only sometimes include sys/signal.h.
It is necessary to compile on Haiku, I'm told.

svn:r1228
2009-04-23 00:21:23 +00:00
Nick Mathewson
e2b987ede1 bump the numeric version; this is not the same as the alpha.
svn:r1224
2009-04-23 00:01:05 +00:00
Nick Mathewson
99de18670e Bump version to 2.0.1-alpha-dev so that nobody mistakes a svn checkout for 2.0.1-alpha.
svn:r1196
2009-04-17 23:07:48 +00:00
Nick Mathewson
d047b323bd Increment version to 2.0.1-alpha, and add a numeric version facility
svn:r1193
2009-04-17 17:22:32 +00:00
Nick Mathewson
7fa8451d7e Add a configure flag to hardcode all of our mm functions.
svn:r1186
2009-04-17 06:56:57 +00:00
Niels Provos
edfc28caef pkgconfig support from Ted Bullock
svn:r1177
2009-04-17 00:24:58 +00:00
Nick Mathewson
52eb495130 Build with the -fno-strict-aliasing flag on GCC.
You do not want to know about the 2 hours I just spent tracking down
an evdns bug that only affected me on some platforms to the way we
were using sockaddr* and sockaddr_in*.  Suffice it to say that I do
not think this is the only C99-aliasing-dubiousness in our code, nor
that I am smart enough to keep my code correct with the GCC's strict
aliasing optimizations in place.

svn:r1079
2009-01-31 07:31:47 +00:00
Niels Provos
fdf694933c sendfile/mmap and memory reference implementation for evbuffers
svn:r1057
2009-01-27 06:05:38 +00:00
Niels Provos
a077fb8c09 rename sys/signal.h to signal.h; configure m4 macro dir; this assist with compilation on Haiku
svn:r1033
2009-01-22 02:47:35 +00:00
Nick Mathewson
309fc7c4ad New functions to provide sane threading callbacks with pthreads and win32 threading implementations.
svn:r1031
2009-01-21 07:51:25 +00:00
Nick Mathewson
a5901991c7 Use eventfd for main-thread notification where available (i.e., linux).
svn:r1023
2009-01-19 20:37:24 +00:00
Nick Mathewson
ec4cfa33c9 Make event_break threadsafe; make notify-thread mechanism a little more generic; let it use pipes where they work.
svn:r1019
2009-01-19 01:34:14 +00:00