2945 Commits

Author SHA1 Message Date
Nick Mathewson
a800b913ac More documentation for finalization feature 2013-04-26 12:18:38 -04:00
Nick Mathewson
4ea4c6a93e Remove bufferevent_del_generic_timeout_cbs as now unused 2013-04-26 12:18:38 -04:00
Nick Mathewson
e9ebef83a0 Always run pending finalizers when event_base_free() is called
There was actually a bug in the original version of this: it tried to
run the finalizers after (potentially) setting current_base to NULL;
but those finalizers could themselves (potentially) be invoking stuff
that needed to know about the current event_base.  So the right time to
do it is _before_ clearing current_base.
2013-04-26 12:18:07 -04:00
Nick Mathewson
02fbf68770 Use finalization feature so bufferevents can avoid deadlocks
Since the bufferevents' events are now EV_FINALIZE (name pending),
they won't deadlock.  To clean up properly, though, we must use the
finalization feature.

This patch also split bufferevent deallocation into an "unlink" step
that happens fast, and a "destruct" step that happens after
finalization.

More work is needed: there needs to be a way to specify a finalizer
for the bufferevent's argument itself.  Also, this finalizer business
makes lots of the reference counting we were doing unnecessary.

Also, more testing is needed.
2013-04-26 12:18:07 -04:00
Nick Mathewson
9d893c97fa Add some verbose notes to bufferevent unit tests 2013-04-26 12:18:07 -04:00
Nick Mathewson
8eedeabe50 Implement event_finalize() and related functions to avoid certain deadlocks 2013-04-26 12:18:07 -04:00
Nick Mathewson
2fad0f3d52 Add an environment variable (EVENT_DEBUG_MODE) to run unit tests in debug mode
Not all tests currently pass with debug mode on.
2013-04-05 15:06:54 -04:00
Nick Mathewson
3339800854 Merge branch '21_empty_strlcpy' 2013-04-01 11:59:26 -04:00
Nick Mathewson
4914620025 Do not build strlcpy.c when it will have no code. 2013-03-31 14:05:26 -04:00
Nick Mathewson
e834006b61 Merge pull request #75 from altf4/master
Header update to specify evbuffer_pullup() behavior
2013-03-29 09:39:52 -07:00
Dan Petro
cf8d1cdb20 Specify return behavior in header for evbuffer_pullup() in corner case
Function returns NULL when told to pullup more data than exists
2013-03-29 09:28:35 -07:00
Nick Mathewson
81ea0c4c7a Merge pull request #47 from ppelleti/https
HTTPS example adapted from Catalin
2013-03-28 05:57:07 -07:00
Nick Mathewson
1bc4a8f99d Merge remote-tracking branch 'origin/patches-2.0' 2013-03-25 21:14:10 -04:00
Nick Mathewson
773b0a5d88 Fix a typo in a comment in buffer.h. Spotted by Alt_F4 2013-03-25 21:12:49 -04:00
Nick Mathewson
f935e2159a build test/test-script.sh on systems with a less-featureful $< 2013-03-15 09:33:28 -04:00
Nick Mathewson
787fd7489f Make --disable-libevent-regress work again 2013-03-15 09:33:13 -04:00
Nate Rosenblum
9443868d55 Double-check next timeout when adding events
When resuming the system from a suspended state, the ev_timeout field
of a scheduled timer event may be in the past. This leads to
unexpected behavior when scheduling a short-duration timer event
immediately after returning from suspension, because the new event
does not land on top of the timeout minheap and so the event loop
(blocked on a possibly long-duration timeout) is not notified.

This patch checks for this condition and, if it obtains, notifies the
event loop.
2013-03-05 11:29:33 -08:00
Azat Khuzhin
13676535c8 Test: decoding just part of string with evhttp_decode_uri_internal() 2013-03-01 12:02:54 +04:00
Azat Khuzhin
de8101a884 Move prototype of evhttp_decode_uri_internal() to http-internal.h
Make it non static, that can be called from tests
2013-03-01 12:00:24 +04:00
Azat Khuzhin
e1903e3ace uri decode: changed the test for the existence of the next character
Fix for 64b6eceaba1a4

More info here
64b6eceaba (commitcomment-2714685)
2013-02-28 23:10:02 +04:00
Azat Khuzhin
64b6eceaba uri decode: fix for warning "use of uninitialised value"
This patch add check in evhttp_decode_uri_internal() that next 2 symbols
are exists in array of chars for decoding, if don't have two next 2
symbols don't try to decode '%FF'
2013-02-28 17:19:44 +04:00
Patrick Pelletier
4db9da6bbf pull in wildcard matching code from cURL
Now, https-client accepts both:

https://ip.appspot.com/ (matching wildcard certificate)
https://github.com/     (matching non-wildcard certificate)

but still rejects

https://www.kegel.com/  (non-matching wildcard certificate)

which should match the behavior of these sites in a web browser.
2013-02-27 21:22:03 -08:00
Patrick Pelletier
6021cb5027 avoid sign mismatch warning in openssl_hostname_validation.c
sample/openssl_hostname_validation.c: In function 'matches_common_name':
sample/openssl_hostname_validation.c:80: warning: comparison between signed and unsigned integer expressions
sample/openssl_hostname_validation.c: In function 'matches_subject_alternative_name':
sample/openssl_hostname_validation.c:124: warning: comparison between signed and unsigned integer expressions
2013-02-27 21:22:03 -08:00
Patrick Pelletier
64d9f161fe use iSECPartners code to validate hostname in certificate
The problem is that if you go to a website whose certificate does not
match its hostname, it should fail.  Try this in a web browser for
https://www.kegel.com/ for example.  Your web browser will say the
certificate is for *.pair.com, not for www.kegel.com, and won't let
you visit it without clicking through a bunch of scary warnings.

However, prior to this commit, https-client was happy to fetch
https://www.kegel.com/ without complaining.  That is bad.  Now, with
this commit, it will properly complain, which is good:

pelletier@chives:~/src/libevent/sample$ ./https-client https://www.kegel.com/
Got 'MatchNotFound' for hostname 'www.kegel.com' and certificate:
/C=US/postalCode=15203/ST=Pennsylvania/L=Pittsburgh/street=Suite 210/street=2403 Sidney Street/O=pair Networks, Inc./OU=Provided by pair Networks, Inc./OU=PairWildcardSSL $250,000/CN=*.pair.com
some request failed - no idea which one though!
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
ppelletier@chives:~/src/libevent/sample$

It will still succeed for sites with an exactly-matching certificate,
such as https://github.com/ and that is also good!

However, the problem is that the iSECPartners code doesn't handle
wildcards, which means we reject https://ip.appspot.com/ even though
it is perfectly legitimate, because we don't understand the wildcard:

ppelletier@chives:~/src/libevent/sample$ ./https-client https://ip.appspot.com/
Got 'MatchNotFound' for hostname 'ip.appspot.com' and certificate:
/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.appspot.com
some request failed - no idea which one though!
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
ppelletier@chives:~/src/libevent/sample$

So, we need to fix this.  In other words, "to be continued..."
2013-02-27 21:22:03 -08:00
Patrick Pelletier
aacd674c94 use Debian's default root certificate location
as suggested here:
http://archives.seul.org/libevent/users/Feb-2013/msg00034.html

although curl's acinclude.m4 reveals many other possibilities:

dnl /etc/ssl/certs/ca-certificates.crt Debian systems
dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
dnl /usr/local/share/certs/ca-root.crt FreeBSD
dnl /etc/ssl/cert.pem OpenBSD
dnl /etc/ssl/certs/ (ca path) SUSE

And none of these cover Windows :(
2013-02-27 21:22:03 -08:00
Patrick Pelletier
5754d96a6e better handling of OpenSSL errors 2013-02-27 21:22:03 -08:00
Patrick Pelletier
42d7441ac4 https-client was putting newlines at 256-byte boundaries
presumably this was meant to put a ">" before every line, but that
isn't what it does, since evbuffer_remove is simply returning
fixed-size chunks.  So, when retrieving a document of more than 256
bytes (e. g. any nontrivial document), we got "> " and newlines thrown
in at very arbitrary places.
2013-02-27 21:22:03 -08:00
Patrick Pelletier
bf31fa5d30 use ${OPENSSL_LIBS} instead of -lssl -lcrypto
This made the difference between segfaulting and not segfaulting for
me when I run https-client, when I've built libevent using an OpenSSL
in a non-standard location.

In the same spirit as 1d9d5110a4aebf5833f6fd78bd0252affde0f4d0 and
d70af27d0152d0a87a25127faf215604beb8ffe0.
2013-02-27 21:22:03 -08:00
Catalin Patulea
be46c99b89 Add sample/https-client.c, an example of stacking evhttp as a client on top of bufferevent_ssl.
Signed-off-by: Catalin Patulea <catalinp@google.com>
2013-02-27 16:06:56 -08:00
Nick Mathewson
87c56727b6 Merge pull request #41 from ppelleti/winsock-errs
FormatMessage for winsock errors
2013-02-26 15:22:03 -08:00
Patrick Pelletier
c9ad3af229 test filling up the hash table a bit 2013-02-25 20:13:01 -08:00
Patrick Pelletier
4ccdd53f78 use hashtable instead of linked list to cache winsock errors
as discussed here:
https://github.com/libevent/libevent/pull/41#issuecomment-13611817
2013-02-25 19:02:32 -08:00
Patrick Pelletier
2078e9b46a make sure caching works, and we don't leak memory 2013-02-14 20:26:38 -08:00
Patrick Pelletier
0c6ec5d816 use FormatMessage for winsock errors
as discussed here:
http://archives.seul.org/libevent/users/Feb-2013/msg00004.html
2013-02-14 20:26:38 -08:00
Patrick Pelletier
729651260d a program to print out the error strings for winsock errors 2013-02-14 18:22:12 -08:00
Nick Mathewson
9709461457 Merge remote-tracking branch 'origin/patches-2.0' 2013-02-14 14:13:11 -05:00
Greg Hazel
b618204216 fix #73 and fix http_connection_fail_test to catch it 2013-02-14 09:54:56 -08:00
Nick Mathewson
96150dd0c6 Unit test for event_remove_timer with EV_PERSIST.
Patch from dcicppin on sourceforge.
2013-02-13 11:41:11 -05:00
Nick Mathewson
5623e80371 Make event_remove_timer behave correctly with persistent timers 2013-02-13 11:41:11 -05:00
Nick Mathewson
74e52db45d Merge remote-tracking branch 'ppelleti/nmake-clean-exes' 2013-02-11 11:25:25 -05:00
Nick Mathewson
2863c83700 Avoid using $(top_srcdir) in TESTS.
Newer automakes don't like this.
2013-02-08 22:10:05 -05:00
Nick Mathewson
ebf278b28d Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake 1.13 compat
Patch from cazfi.
2013-02-08 22:09:56 -05:00
Nick Mathewson
d670e3bd35 Merge remote-tracking branch 'origin/patches-2.0'
This is an "ours" commit: I'm not taking the recent autotools changes
from patches-2.0, since they'd conflict with master.
2013-02-08 22:09:00 -05:00
Nick Mathewson
a55514eeed Avoid using top_srcdir in TESTS-new automakes do not like this 2013-02-08 22:08:18 -05:00
Nick Mathewson
0c79787a97 Rename configure.in to configure.ac to appease newer autoconfs 2013-02-08 22:07:47 -05:00
Nick Mathewson
817ea36924 Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake 1.13 compat
Patch from cazfi.
2013-02-08 13:03:29 -05:00
Patrick Pelletier
a452811e41 "buffer" spelling 2013-02-07 17:55:36 -08:00
Patrick Pelletier
974bfa0782 remove all exes on "make clean", not just regress.exe 2013-02-07 17:55:36 -08:00
Nick Mathewson
2901542714 Merge remote-tracking branch 'origin/patches-2.0' 2013-02-05 15:09:31 -05:00
Nick Mathewson
0a5eb2eb5c Fix a locking error in bufferevent_socket_get_dns_error.
Patch from Ka-Hing Cheung.
2013-02-05 15:07:32 -05:00