bufferevent_openssl.c


Log

Author Commit Date CI Message
Nick Mathewson 909c40e5 2011-08-03T12:12:47 Merge remote-tracking branch 'origin/patches-2.0'
Joachim Bauch 4a343943 2011-07-26T10:31:18 Propagate errors on the underlying bufferevent to the user.
Nick Mathewson c116d960 2011-07-04T11:37:52 Merge remote-tracking branch 'origin/patches-2.0'
Joachim Bauch e050703d 2011-07-04T11:36:14 Fix bug in SSL bufferevents backed by a bev with a write high-watermarks Original mail: the logic that handles write watermarks in "bio_bufferevent_write" is not working. It currently doesn't write any data if the high watermark is *above* the amount of data to write (i.e. when there is actually enough room available).
Nick Mathewson 9f560bfa 2011-05-25T19:50:56 Use "_WIN32", not WIN32: it's standard and we don't need to fake it This patch was automatically generated with perl. Based on a patch by Peter Rosin.
Nick Mathewson 614a1712 2011-04-22T23:46:25 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: evthread.c
Sebastian Hahn 65707d7c 2011-04-11T17:40:14 add some (void) casts for unused variables All these places already have an XXX marker, so we know we need to fix them later. Let's not clutter the static analysis results with them.
Kevin Bowling 0915ca0a 2011-01-02T08:43:45 Include evconfig-private.h in internal files for great good.
Nick Mathewson 29f7623c 2010-11-29T22:14:54 Possible crash fix when freeing an underlying bufferevent of an openssl bufferevent
Nick Mathewson 4f228a1f 2010-11-14T19:52:18 Fix bug in bufferevent_connect on an openssl bufferevent that already had an fd The problem was that we were using openssl's BIO code's shutdown flag whenever BEV_OPT_CLOSE_ON_FREE was set. This made the BIO close the socket when it was freed... but it would be freed whenever we did a setfd on the bufferevent_openssl, even the no-op setfd in bufferevent_connect. So instead, we just set the shutdown flag to 0, and handle closing the fd ourselves. Spotted by Linus Nordberg
Nick Mathewson 1ac5b230 2010-11-09T15:18:59 Only clear underlying callbacks when the user hasn't reset them.
Nick Mathewson fc7b1b00 2010-11-09T11:43:47 When closing a filtering bufferevent, clear callbacks on the underlying bufferevent Previously, if BEV_OPT_CLOSE_ON_FREE wasn't set on a bufferevent_filter or a filtering bufferevent_openssl, when we went to free the filtering bufferevent, we'd leave the underlying bufferevent unchanged. That's not so good, since the callbacks are set to activate stuff in the filtering bufferevent that we're about to free. Instead, set all the callbacks to NULL.
Nick Mathewson 1213d3dd 2010-10-20T13:41:02 Fix a 100%-CPU bug where an SSL connection would sometimes never stop trying to write If an SSL connection becamse disabled or suspended before became open, it could (under the right circumstances) wind up without ever getting its write callback disabled. The most correct fix is probably more subtle, and involves checking all caseswhen a write callback is enabled or disabled. This fix is more blunt, and explicitly checks whether the callback should have been disabled at the end of the callback to prevent infinite looping. Diagnosed with help from Sebastian Hahn
Nick Mathewson 93bb7d8e 2010-10-14T11:41:10 Fix a case where an ssl bufferevent with CLOSE_ON_FREE didn't close its fd This could happen when we got an SSL with a BIO already set on it.
Nick Mathewson 223ee40f 2010-10-14T10:53:26 Avoid spurious reads from just-created open openssl bufferevents When handshaking, we listen for reads or writes from the transport. But when we're connected, we start out with writes enabled and reads disabled, which means we should not have the transport read for us.
Nick Mathewson ac27eb82 2010-10-08T00:59:02 Correct logic on disabling underlying bufferevents when disabling a filter Previously, whenever writing was disabled on a bufferevent_filter (or a filtering SSL bufferevent), we would stop writing on the underlying bufferevent. This would make for trouble, though, since if you implemented common patterns like "stop writing once data X has been flushed", your bufferevent filter would disable the underlying bufferevent after the data was flushed to the underlying bufferevent, but before actually having it written to the network. Now, we have filters leave their underlying bufferevents enabled for reading and writing for reading and writing immediately. They are not disabled, unless the user wants to disable them, which is now allowed. To handle the case where we want to choke reading on the underlying bufferevent because the filter no longer wants to read, we use bufferevent_suspend_read(). This is analogous to the way that we use bufferevent_suspend_write() to suspend writing on a filtering bufferevent when the underlying bufferevent's output buffer has hit its high watermark.
Nick Mathewson 819b1715 2010-10-12T12:59:13 Handle rate-limiting for reading on OpenSSL bufferevents correctly. We were looking at the number of bytes read on the wbio, not in the rbio. But these are usually different BIOs, and the reading is supposed to happen on the rbio.
Nick Mathewson 743f8665 2010-08-23T11:48:46 Honor NDEBUG; build without warnings with NDEBUG; make NDEBUG always-off in unit test code
Nick Mathewson ec347b92 2010-07-07T16:45:03 Move event-config.h to include/event2 This change means that all required include files are in event2, and all files not in event2/* are optional.
Nick Mathewson 009f3005 2010-08-04T14:54:38 Fix rate-limit calculation on openssl bufferevents. When you're doing rate limiting on an openssl connection, you nearly always want to limit the number of bytes sent and received over the wire, not the number of bytes read or written over the secure transport.
Mike Smellie c9913174 2010-07-19T15:31:19 Change bufferevent_openssl::do_write so it doesn't call SSL_write with a 0 length buffer I was running into a problem when using bufferevent_openssl with a very simple echo server. My server simply bufferevent_read_buffer 'd data into an evbuffer and then passed that evbuffer straight to bufferevent_write_buffer. The problem was every now and again the write would fail for no apparent reason. I tracked it down to SSL_write being called with the amount of data to send being 0. This patch alters do_write in bufferevent_openssl so that it skips io_vecs with 0 length.
Nick Mathewson 657d1b6d 2010-03-13T01:06:57 Set mem_offset for every bufferevent type
Nick Mathewson 75018951 2010-03-13T00:23:06 Fix a possible double-free bug in SSL bufferevents with CLOSE_ON_FREE With CLOSE_ON_FREE set, we were telling the BIO to free the bufferevent when it was closed, and also freeing it ourselves.
Nick Mathewson f1bc125e 2010-03-12T23:00:49 Improve robustness for refcounting Document that we do intend to double-decref underlying bufferevents under some circumstances. Check to make sure that we don't decref past 0.
Nick Mathewson 17efc1cd 2010-03-04T01:25:51 Update all our copyright notices to say "2010"
Nick Mathewson d3288293 2010-02-20T18:44:35 Provide consistent, tested semantics for bufferevent timeouts The different bufferevent implementations had different behavior for their timeouts. Some of them kept re-triggering the timeouts indefinitely; some disabled the event immediately the first time a timeout triggered. Some of them made the timeouts only count when the bufferevent was actively trying to read or write; some did not. The new behavior is modeled after old socket bufferevents, since they were here first and their behavior is relatively sane. Basically, each timeout disables the bufferevent's corresponding read or write operation when it fires. Timeouts are stopped whenever we suspend writing or reading, and reset whenever we unsuspend writing or reading. Calling bufferevent_enable resets a timeout, as does changing the timeout value.
Nick Mathewson e5bbd40a 2010-02-18T17:41:15 Clean up formatting: use tabs, not 8-spaces, to indent.
Nick Mathewson ff3f6cd4 2010-01-22T16:14:49 Check more internal event_add() calls for failure Most of these should be unable to fail, since adding a timeout generally always works. Still, it's better not to try to be "too smart for our own good here." There are some remaining event_add() calls that I didn't add checks for; I've marked those with "XXXX" comments.
Nick Mathewson ba2945f9 2010-01-06T17:59:44 Merge branch 'ratelimit' Conflicts: bufferevent_async.c
Nick Mathewson 2e8eeea3 2009-12-29T19:50:03 Fix crash bugs when a bufferevent's eventcb is not set. In many places throughout the code, we called _bufferevent_run_eventcb without checking whether the eventcb was actually set. This would work fine when the bufferevent's callbacks were deferred, but otherwise the code would segfault. Strangely, we always remembered to check before calling the _bufferevent_run_{read,write}cb functions. To prevent similar errors in the future, all of _buferevent_run_{read,write,event}cb now check to make sure the callback is actually set before invoking or deferring the callback. This patch also removes the now-redundant checks for {read,write}cb.
Nick Mathewson 82743794 2009-12-24T17:47:14 Do not make bufferevent_setfd implicitly disable EV_READ and EV_WRITE. This obviates the need for BEV_SUSPEND_CONNECTING, and good riddance.
Nick Mathewson 737c9cd8 2009-11-27T13:16:54 Rate-limiting for bufferevents; group and individual limits are supported. The fairness algorithms are not the best, not every bufferevent type is supported, and some of the locking tricks here are simply absurd. Still, this code should be a good first step.
Joachim Bauch a773df54 2009-12-18T16:24:41 Fix a segfault when freeing SSL bufferevents in an unusual order Have container bufferevents hold a reference to their underlying bufferevents. (Commit message and minor revisions by nickm.)
Joachim Bauch a6adeca7 2009-12-17T12:38:46 Fix a segfault when writing a very fragmented evbuffer onto an SSL Fixes bug 2916328.
Nick Mathewson 26573d3d 2009-11-09T19:37:15 Change an err to a warn in bufferevent_openssl svn:r1523
Nick Mathewson 784b8773 2009-11-06T21:46:57 We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H svn:r1516
Nick Mathewson 34f28e08 2009-11-05T15:57:22 Fix a few types to use compatible versions svn:r1501
Nick Mathewson 516452b7 2009-10-30T21:08:29 Keep openssl errors associated with the right bufferevent object. OpenSSL has a per-thread error stack, and really doesn't like you leaving errors on the stack. Rather than discard the errors or force the user to handle them, this patch pulls them off the openssl stack and puts them on a stack associated with the bufferevent_openssl. If the user leaves them on the stack then, it won't affect any other connections. This bug was found by Roman Puls. Thanks! svn:r1481
Nick Mathewson 2e36dbe1 2009-10-26T20:00:43 Use EVUTIL_ASSERT() consistently instead of assert. svn:r1464
Nick Mathewson b73ad7bc 2009-10-21T18:48:22 Treat the bitwise OR of two enum values as an int. This makes our interfaces usable from C++, which doesn't believe you can say "bufferevent_socket_nase(base, -1, BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS)" but which instead would demand "static_cast<bufferevent_options>(BEV_OPT_CLOSE_ON_FREE| BEV_OPT_DEFER_CALLBACKS))" for the last argument. Diagnosis and patch from Chris Davis. svn:r1456
Nick Mathewson e3fd294a 2009-10-16T13:19:57 Spelling fixes in comments and strings. svn:r1445
Nick Mathewson f2282398 2009-08-14T20:07:35 New function to put an SSL bufferevent into a renegotiating state. svn:r1418
Nick Mathewson 46a61869 2009-08-14T20:07:17 Disable whichever struct event we don't want during ssl handshaking. svn:r1417
Nick Mathewson 58b0708e 2009-08-14T20:07:09 Only send a connected event _after_ we've adjusted the SSL state. This is important if the callback adjusts it to something else. svn:r1416
Nick Mathewson cf54d74a 2009-07-30T20:41:41 More unit tests for Openssl, including initializing with no socket. Up to 75% coverage. svn:r1399
Nick Mathewson 7a2a51a3 2009-07-30T20:41:21 Add unit tests for SSL session renegotiation. This tickles the write-blocked-on-read code, and in this case turned up a bug in it. svn:r1397
Nick Mathewson 595f7e38 2009-07-30T20:41:12 Always retry SSL_write() with the same number you told it last time. svn:r1396
Nick Mathewson eecefc50 2009-07-30T20:41:00 Add a function to extract the SSL object from a bufferevent_openssl. svn:r1395
Nick Mathewson d5a3f1f1 2009-07-30T20:40:50 Set the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag, and explain why. svn:r1394
Nick Mathewson 44715517 2009-07-30T20:40:40 Use SSL_do_handshake in place of SSL_connect/SSL_accept svn:r1393
Nick Mathewson 709c21c4 2009-07-28T04:03:57 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