2369 Commits

Author SHA1 Message Date
Kurt Roeckx
19e839c7bb Make it build using OpenSSL 1.1.0
Rebased (azat):
- tabs instead of whitespaces
- make openssl-compat.h safe for complex expressions
- do not call sk_SSL_COMP_free() in 1.1 (fixes double free)

TODO:
- clean methods_bufferevent

Refs: #397 (cherry-picked)
(cherry picked from commit 3e9e0a0d46e4508e8782ec3787c6d86bab63046d)
2019-11-24 02:38:28 +03:00
Azat Khuzhin
4294867cbc
Bump version to 2.0.23-beta
Tested on:
- arch linux (openssl 1.0)
- ubuntu (https://travis-ci.org/libevent/libevent/branches patches-2.0)
- freebsd (libevent-extras in vagrant)
- osx (libevent-extras in vagrant)

Refs: #744
release-2.0.23-beta
2019-01-20 23:00:26 +03:00
Azat Khuzhin
9a88d75c70
Release notes for 2.0.23-beta
[ Based on commit c87a0680 ]
2019-01-20 22:47:53 +03:00
Azat Khuzhin
4300faad8a
Update ACKNOWLEDGMENTS section for 2.0.23-beta 2019-01-20 22:47:33 +03:00
Azat Khuzhin
2f656ffb23
test/buffer: write >GETPIPE_SZ via events over pair to avoid stall
[ Upstream commit 0aad01436af27c5807d48701028020bb51cba387 ]
2019-01-20 22:47:33 +03:00
Jesse Fang
d22efeb134
bufferevent_socket_connect{,_hostname}() missing event callback and use ret code
[ Upstream commit f7bc1337977553f5f966f13840a5f7feba2d0bd5 ]

- When socket() failed in bufferevent_socket_connect() , the event
  callback should be called also in
  bufferevent_socket_connect_hostname().  eg. when use
  bufferevent_socket_connect_hostname() to resolve and connect an IP
  address but process have a smaller ulimit open files, socket() fails
  always but caller is not notified.

- When make socket nonblocking failed in bufferevent_socket_connect(),
  free the fd.

- Make bufferevent_socket_connect()'s behavior more consistent: function
  return error then no callback, function return ok then error passed by
  event callback.

Backport-for: 2.0
Refs: #597
Refs: #599
Refs: #600
Closes: #599 (cherry-pick)
2019-01-20 19:53:45 +03:00
Azat Khuzhin
d148783103
Preserve ET bit for backends with changelist
[ Upstream commit a1293bd2e626cba1f687cd0e50a219f8661775fc ]

Fixes: #636
2019-01-20 19:53:45 +03:00
Isidor Kouvelas
63306e6f41
Epoll ET setting lost with multiple events for same fd
[ Upstream commit b77d3e787b5522380c65838d3baa22e661eff0db ]

After two or more events have been registered for the same file
descriptor using EV_ET, if one of the events is deleted, then the
epoll_ctl() call issued by libevent drops the EPOLLET flag resulting in
level triggered notifications.

[ azat: test for EV_ET for EPOLL_CTL_MOD too, for libevent 2.0 ]

Fixes: #636
2019-01-20 19:53:45 +03:00
Isidor Kouvelas
70a39d458b
Cover ET with multiple events for same fd
[ Upstream commit 77c0e510581b88242d7d7bcff4954cedc5613554 ]

Refs: #636
2019-01-20 19:53:45 +03:00
Mike Frysinger
a8a315ec19
ignore config.cache/test-driver files
[ Upstream commit c83f3333a34251275c38878e9667c904a485ac6d ]

config.cache is generated when you run `./configure -C`.

test-driver comes from newer autotools.
2019-01-20 19:53:44 +03:00
Maxime Henrion
db6c5dfb3c
If evsel->del() fails, don't leave the evmap in an inconsistent state.
[ Upstream commit 9b5a527f5bf898250a797dde59cadb4f64e8967a ]

 This fixes assertion failures in cases where epoll() fails with EBADF
 -- the root cause for which is as of yet unknown. It seems something
 (OpenSSL?) is closing the file descriptor under our feet.
2019-01-20 19:53:44 +03:00
Azat Khuzhin
c52cdc28f5
Add travis-ci configuration
But since 2.0 version has parallel test harness (see automake) we need
to show test/test-suite.log manually.
2018-10-25 20:32:46 +03:00
Nick Mathewson
4d73149fa1
Remove integer-overflow unit tests
[ Upstream commit e5302ac7 ]
[ Fixes clang builds -- https://travis-ci.org/azat/libevent/jobs/446053765 ]

There's not much point checking undefined behavior.
2018-10-25 20:32:45 +03:00
Nick Mathewson
3384582443
Correctly skip ipv6 http test on systems without ipv6
[ Upstream commit 6a1c4d50 ]
2018-10-25 20:32:45 +03:00
Nick Mathewson
b52e95f525
Skip http/ipv6_for_domain test when we have no ipv6 support
[ Upstream commit 21477e40 ]
2018-10-25 20:32:45 +03:00
Azat Khuzhin
6f18f88ee7
Remove for loop initial declaration and fix conflicting type in it (gcc 4.8)
From [1]:
  regress_buffer.c:742:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (int i = 0; i < 1 << 16; ++i) {
     ^
  regress_buffer.c:742:3: note: use option -std=c99 or -std=gnu99 to compile your code
  regress_buffer.c:787:23: error: conflicting types for ‘bufread’
    for (int n = toread, bufread = toread;
                         ^
  regress_buffer.c:717:51: note: previous definition of ‘bufread’ was here
    size_t datalen = strlen(data), toread = datalen, bufread = 0;
                                                     ^
  regress_buffer.c:787:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
    for (int n = toread, bufread = toread;
    ^

[1]: https://travis-ci.org/azat/libevent/jobs/445501665
2018-10-25 20:32:45 +03:00
Mark Mentovai
6762a4d653
Check for Mac OS X 10.4 kqueue bug properly
[ Upstream commit df6f99e5 ]
[ Fixes: #377 ]

EV_ERROR is a bit in struct kevent::flags. Other bits may be set too.

Actually we have osx builds on travis-ci, but it uses osx 10.9.5, and we don't
have warnings there, since I guess that there is no OR'ing with previous flag
in case of error, while in 10.12 there is OR.

Fixes: #377
Fixes: #376
Link: https://crbug.com/626534
Link: https://travis-ci.org/libevent/libevent/jobs/141033429
2018-10-24 01:41:37 +03:00
Azat Khuzhin
b2beaad668
Skip all dns tests that hit the network
But since this version of tinytest do not have TT_OFF_BY_DEFAULT use
TT_SKIP instead.

[ Upstream commit f2cea873bb8c4e1e89cc282470a11556e4bd9730 ]
2018-10-24 01:25:07 +03:00
Azat Khuzhin
9e6f650302
Simplify bufferevent timeout tests to reduce CPU usage in between start/compare
[ Upstream commit 6ac8e775 ]
[ Fixes: #262 ]

Between start (setting "started_at") and comparing the time when
timeouts triggered with the start (test_timeval_diff_eq), there is too
much various things that can introduce extra delays and eventually could
fail the test on machine with shortage of CPU.

And this is exactly what happend on:
- travis-ci
- #262

Here is a simple reproducer that I came up with for this issue:
  docker run --cpus=0.01 -e LD_LIBRARY_PATH=$PWD/lib -e PATH=/usr/bin:/bin:$PWD/bin -v $PWD:$PWD --rm -it debian:testing regress --no-fork --verbose bufferevent/bufferevent_timeout

Under limited CPU (see reproducer) the test almost always has problems
with that "write_timeout_at" exceed default timeval diff tolerance
(test_timeval_diff_eq() has 50 tolerance), i.e.:
  FAIL ../test/regress_bufferevent.c:1040: assert(labs(timeval_msec_diff(((&started_at)), ((&res1.write_timeout_at))) - (100)) <= 50): 101 vs 50

But under some setup write timeout can even not triggered, and the
reason for this is that we write to the bufferevent 1024*1024 bytes, and
hence if evbuffer_write_iovec() will has some delay after writev() and
not send more then one vector at a time [1], it is pretty simple to
trigger, i.e.:
  FAIL ../test/regress_bufferevent.c:1040: assert(labs(timeval_msec_diff(((&started_at)), ((&res1.write_timeout_at))) - (100)) <= 50): 1540155888478 vs 50

  [1]: https://gist.github.com/azat/b72773dfe7549fed865d439e03de05c1

So this patch just send static small payload for all cases (plus a few
more asserts added).

The outcome of this patch is that all regression tests passed on
travis-ci for linux box [2]. While before it fails almost always [3].
Also reproducer with CPU limiting via docker also survive some
iterations (and strictly speaking it should has less CPU then travis-ci
workers I guess).

  [2]: https://travis-ci.org/azat/libevent/builds/444391481
  [3]: https://travis-ci.org/libevent/libevent/builds/444336505
2018-10-24 01:07:09 +03:00
Azat Khuzhin
90ae4c5013 Merge branch 'evbuffer_add_file-2.0-fixes' into patches-2.0
Bunch of fixes for evbuffer_add_file().

* evbuffer_add_file-2.0-fixes:
  Cover evbuffer_add_file() with offset
  evbuffer_add_file: do not use evbuffer_remove(), instead calc offset for mmap()
  evbuffer_add_file: munmap() correct size on mmap() failure
  evbuffer_add_file: fix endless loop when file does not have such amount of data

Fixes: #306
2017-12-18 02:28:15 +03:00
Azat Khuzhin
dd3e841c75 Cover evbuffer_add_file() with offset 2017-12-18 02:21:47 +03:00
Azat Khuzhin
2653be970a evbuffer_add_file: do not use evbuffer_remove(), instead calc offset for mmap()
@ellzey:
   "when evbuffer_add_file is called and mmap is used, if the offset
    argument is >0, a mistake happens: add_file removes "offset" byts
    from the front of the evbuffer.
    So that means any data that was previously on the buffer is trimmed
    off by "offset" bytes. Whoops."

And even more when offset>0, evbuffer_add_file() still maps whole file,
let's calc appropriate offset and length.

And here is the wrong fix:
  afca576a05
2017-12-18 02:21:47 +03:00
Azat Khuzhin
765c35d4a8 evbuffer_add_file: munmap() correct size on mmap() failure 2017-12-18 01:53:19 +03:00
Azat Khuzhin
226b927813 evbuffer_add_file: fix endless loop when file does not have such amount of data 2017-12-18 01:29:56 +03:00
Mark Ellzey
7dedc077aa
Backport for #340 (fix overflow check in expand_singlechain()
Refs: #306
Fixes: #340
Fixes: 20d6d44
2016-06-28 11:11:51 -07:00
Azat Khuzhin
9b2a670974 Ignore all pkgconfig generated stuff 2016-05-02 12:37:19 +03:00
Jan Heylen
a5b4b7a1b0 libevent_core and libevent_extra also deserve a pkgconfig file 2016-04-24 10:56:39 +02:00
Azat Khuzhin
f4b28a6c70 Merge remote-tracking branch 'origin/pr/338' into patches-2.0
* origin/pr/338:
  evbuffer_add: Use last_with_datap if set, not last.
  Use the free-trailing-chains function in evbuffer_insert_chain too
  test/regress: add tests for evbuffer_add() breakage on empty last chain

Fixes: #335
2016-03-29 19:27:07 +03:00
Marcus Sundberg
b00db82a83 evbuffer_add: Use last_with_datap if set, not last.
evbuffer_add() would always put data in the last chain, even if there
was available space in a previous chain, and in doing so it also
failed to update last_with_datap, causing subsequent calls to other
functions that do look at last_with_datap to add data in the middle
of the evbuffer instead of at the end.

Fixes the evbuffer_add() part of issue #335, and the evbuffer/add2 and
evbuffer/add3 tests, and also prevents wasting space available in the
chain pointed to by last_with_datap.
2016-03-26 20:49:27 +01:00
Nick Mathewson
0e894fb7f3 Use the free-trailing-chains function in evbuffer_insert_chain too 2016-03-26 20:49:08 +01:00
Marcus Sundberg
0091da360a test/regress: add tests for evbuffer_add() breakage on empty last chain
The evbuffer/add* tests currenly break on 2.0.21, 2.0.22 and 2.1 HEAD
due to issue #335. The evbuffer/reference2 test breaks on 2.0.21 and
2.0.22 due to commit b18c04dd not being applied.
2016-03-26 20:48:01 +01:00
Azat Khuzhin
a4a7c1aedd Merge branch 'fix-http-for-ipv6-backport-for-2.0' into patches-2.0
This patchset is just a backport from upstream (with minor fixes to function
names in tests) of 2ecd894725e167dcc1f22f9292f98e41299df6cc ("Merge pull
request #39 from azat/fix-http-for-ipv6")

* fix-http-for-ipv6-backport-for-2.0:
  Add regress test ipv6_for_domain.
  Fix ipv6 support for http. When URL contain domain, not IP address.

Fixes #287
2015-10-08 11:51:55 +03:00
Azat Khuzhin
066a4f6fd1 Add regress test ipv6_for_domain.
Written for commit 71e709c7829275a594f767b27468b1b52e8b5bb9.
Fix ipv6 support for http. When URL contain domain, not IP address.

backporting to 2.0: fix conflicts with the name of the main function --
_http_connection_test().
2015-10-08 11:48:02 +03:00
Azat Khuzhin
502c043a3a Fix ipv6 support for http. When URL contain domain, not IP address.
Before this patch socket created before domain was resolved, and it
always create with AF_INET (ipv4), but we must create socket only after
domain was resolved to understad which protocol family have domain
address.

Thank to Patrick Pelletier, who found this bug.
2015-10-08 11:44:49 +03:00
Mark Ellzey
571dbac81a Fix potential fd leak in listener_read_cb()
As pointed out by harlan_ in #libevent after running a coverity sweep.
If the listener is free'd, 'new_fd' is never closed.
2015-04-27 22:59:42 -04:00
Nick Mathewson
c51b159cff Update changelog release-2.0.22-stable 2015-01-05 10:17:40 -05:00
Nick Mathewson
1cd9c90596 Update changelog. 2015-01-05 09:31:12 -05:00
Nick Mathewson
489b07132f Merge branch '20_cve_2014_6272_v2' into patches-2.0 2015-01-05 09:30:02 -05:00
Nick Mathewson
079e6ddc19 Increment version to 2.0.22-stable 2015-01-05 09:18:59 -05:00
Nick Mathewson
9b855a09ef Update changelog for 2.0 2015-01-05 08:46:22 -05:00
Nick Mathewson
20d6d4458b Fix CVE-2014-6272 in Libevent 2.0
For this fix, we need to make sure that passing too-large inputs to
the evbuffer functions can't make us do bad things with the heap.

Also, lower the maximum chunk size to the lower of off_t, size_t maximum.

This is necessary since otherwise we could get into an infinite loop
if we make a chunk that 'misalign' cannot index into.
2015-01-05 08:42:32 -05:00
Nick Mathewson
fb7e76aec5 Fix evbuffer_peek() with len==-1 and start_at non-NULL. 2014-12-01 08:32:05 -05:00
Nick Mathewson
1da2f42bdb Merge branch 'patches-2.0' of github.com:libevent/libevent into patches-2.0 2014-11-30 21:02:25 -05:00
Nick Mathewson
5ae5287214 Work on the changelog for 2.0.22 2014-11-30 19:38:23 -05:00
vjpai
3c7d6fcaff Fix race caused by event_active
There is a race between manual event_active and natural event activation. If both happen at the same time on the same FD, they would both be protected by the same event base lock except for 1 LoC where the fields of struct event are read without any kind of lock. This commit does those reads into local variables inside the lock and then invokes the callback with those local arguments outside the lock. In 2.0-stable, none of this is inside the lock; in HEAD, only the callback is read inside the lock. This gets the callback and all 3 arguments inside the lock before calling it outside the lock.
2014-11-30 19:24:15 -05:00
Nick Mathewson
be1aeff21a Fix a typo in a doxygen comment. Reported by 亦得. 2014-10-09 10:14:12 -04:00
ufo2243
b34e4ac3a4 [Bugfix] fix bufferevent setwatermark suspend_read 2014-09-18 15:07:41 -04:00
Maks Naumov
79800df7c7 regress_buffer: fix 'memcmp' compare size 2014-09-18 11:33:20 -04:00
Nick Mathewson
60f8f729d3 Consistently check for failure from evbuffer_pullup()
Closes issue #148.
2014-08-29 14:59:17 -04:00
Nick Mathewson
6466e88ac1 Use FindClose for handle from FindFirstFile in http-server.c
Noted by Miles Chan as issue #145
2014-08-29 14:31:07 -04:00