4182 Commits

Author SHA1 Message Date
Azat Khuzhin
2d4ac10ea4
becat: remove extra SSL_CTX options usage [ci skip]
Because:
- this do not affects performance
- this breaks builds for with older openssl
2019-06-02 21:55:31 +03:00
Azat Khuzhin
7d569b0faf
Fix detection of the __has_attribute() for apple clang [ci skip]
Fixes build on the next osx env:
- Mac OS 10.9/clang 600
- Mac OS 10.8/clang 500

Refs: https://github.com/libevent/libevent/issues/447#issuecomment-497908488
2019-06-02 21:47:43 +03:00
wenyg
891dd1880f
https-client: correction error checking
When connecting to a non-existent HTTPS service, the "req" is not null
but the "evhttp_request_get_response_code(req)" is zero.

Closes: #822 (cherry-picked)
2019-06-01 00:41:25 +03:00
yuangongji
c03dabd76a typo error in header file 2019-05-31 02:12:55 +08:00
Jan Beich
236762a30d cmake: limit MSVC to Clang-CL 2019-05-28 12:45:59 +00:00
Azat Khuzhin
1c573ab3a9
http: do not name variable "sun" since this breaks solaris builds
-bash-3.2$ /opt/csw/bin/gcc -xc /dev/null -dM -E | grep '#define sun'
  #define sun 1
2019-05-25 23:41:38 +03:00
Azat Khuzhin
51ac04ac62
test: mark bev_connect_hostname() as static (to avoid prototype requirement) 2019-05-25 17:29:55 +03:00
Azat Khuzhin
49a367e6cf
cmake: add -Wmissing-prototypes (like autotools has) 2019-05-25 17:28:53 +03:00
Azat Khuzhin
4c774b6ceb
time-test: disable buffering (mostly for windows) 2019-05-21 10:59:05 +03:00
Azat Khuzhin
3b1864b625
Merge branch 'evbuffer-fixes-806-v2'
* evbuffer-fixes-806-v2:
  evbuffer: fix last_with_datap after prepend with empty chain
  test: regression for evbuffer_expand_fast_() with invalid last_with_datap
  test: cover adjusting of last_with_datap in evbuffer_prepend()

Fixes: #806
2019-05-16 10:25:50 +03:00
Azat Khuzhin
401bd1c09e
evbuffer: fix last_with_datap after prepend with empty chain
last_with_datap should be adjusted only if it buf->first *was* not
empty, otherwise last_with_datap should point to the prepended chain.
2019-05-16 10:16:21 +03:00
Azat Khuzhin
244cacaf8c
test: regression for evbuffer_expand_fast_() with invalid last_with_datap
Before the fix:
  $ regress --no-fork evbuffer/reserve_invalid_last_with_datap
  evbuffer/empty_chain_expand: [err] ../buffer.c:2138: Assertion chain == buf->first failed in evbuffer_expand_fast_
  Aborted (core dumped)

This is the a shorter version of test from the #806 (with some
comments).
2019-05-16 10:16:21 +03:00
Azat Khuzhin
98ca307749
test: cover adjusting of last_with_datap in evbuffer_prepend()
Before the fix:
  $ regress evbuffer/empty_reference_prepend..
  evbuffer/empty_reference_prepend: [forking]
    FAIL ../test/regress_buffer.c:104: assert(chain == buf->first)
    FAIL ../test/regress_buffer.c:2291: Buffer format invalid
    [empty_reference_prepend FAILED]
  evbuffer/empty_reference_prepend_buffer: [forking] OK
  1/2 TESTS FAILED. (0 skipped)
2019-05-16 10:05:07 +03:00
Azat Khuzhin
c8b403a81b
Add getopt into dist archive
Fixes: #815
2019-05-15 21:29:03 +03:00
Joseph Spadavecchia
5e137f3776
Implement bufferevent_socket_connect_hostname_hints()
So that ai_flags (such as AI_ADDRCONFIG) can be specified.

Closes: #193 (cherry-picked with conflicts resolved)
2019-05-13 11:13:04 +03:00
Azat Khuzhin
76eded24d3
Merge branch 'issue-807-accept4-getnameinfo-AF_UNIX'
* issue-807-accept4-getnameinfo-AF_UNIX:
  http-server: add usage/help dialog
  http: avoid use of uninitialized value for AF_UNIX/AF_LOCAL sockaddr
  http-server: add ability to bind to unix-socket
  build: struct sockaddr_un detection (sys/un.h, afunix.h)

Fixes: #807
2019-05-12 19:06:43 +03:00
Azat Khuzhin
c4de602433
http-server: add usage/help dialog 2019-05-12 18:44:20 +03:00
Azat Khuzhin
ad51a3c1ba
http: avoid use of uninitialized value for AF_UNIX/AF_LOCAL sockaddr
unixsock peer does not have sun_path initialized.
2019-05-12 18:21:21 +03:00
Azat Khuzhin
737d1beb14
http-server: add ability to bind to unix-socket
Usage example:
  http-server -u -U /tmp/sock /tmp/no-such-dir
  curl -v --unix-socket /tmp/sock 127.1:8080/foo
2019-05-12 18:21:21 +03:00
Azat Khuzhin
da11217544
build: struct sockaddr_un detection (sys/un.h, afunix.h)
- On UNIX:     sys/un.h
- Since win10: afunix.h

And windows has AF_UNIX but do not have sockaddr_un (before windows
build 17061 [1]), hence the sockaddr_un detection.

  [1]: https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
2019-05-12 18:17:53 +03:00
Tobias Stoeckmann
2707a4ffab
kqueue: Avoid undefined behaviour.
As ploxiln pointed out in pull request 811 the check "newsize < 0"
is undefined behaviour (signed int overflow).

Follow the advice and check kqop->changes_size instead.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Closes: #813 (cherry-picked)
2019-05-11 11:29:55 +03:00
Tobias Stoeckmann
cf8acae36a Prevent integer overflow in kq_build_changes_list.
On amd64 systems with kqueue (e.g. *BSD systems) an integer overflow
could be triggered with an excessively huge amount of events.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2019-05-07 20:53:17 +02:00
zhuizhuhaomeng
8701d0d3d2
evdns: fix lock/unlock mismatch in evdns_close_server_port()
Closes: #809 (cherry-picked)
2019-05-06 10:37:18 +03:00
Azat Khuzhin
c6becb26ca
Merge remote-tracking branch 'official/pr/804'
* official/pr/804:
  Added test for evmap slot validations.
  Prevent endless loop in evmap_make_space.
  Enforce limit of NSIG signals.
2019-04-30 08:43:27 +03:00
Tobias Stoeckmann
9b2060c97a Added test for evmap slot validations.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2019-04-27 11:47:23 +02:00
Tobias Stoeckmann
bd817009d5 Prevent endless loop in evmap_make_space.
If slot is larger than INT_MAX / 2, then the loop which increases
nentries until it is larger than slot would never return.

Also make sure that nentries * msize will never overflow INT_MAX.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2019-04-26 18:15:57 +02:00
Tobias Stoeckmann
4a1088baf4 Enforce limit of NSIG signals.
It doesn't make sense to allow a signal number higher than NSIG.

The NSIG check already exists in signal.c for internally used
functions.

As this is a programming error of libevent consumers, this is a
purely defensive mechanism.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2019-04-26 18:15:50 +02:00
Tobias Stoeckmann
176fd56655
Protect min_heap_push_ against integer overflow.
Converting unsigned to size_t for size of memory objects allows
proper handling of very large heaps on 64 bit systems.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Closes: #799 (cherry-picked)
2019-04-22 23:51:25 +03:00
linxiaohui
16d8564a2c
le-proxy: initiate use of the Winsock DLL
Closes: #803 (cherry-picked)
2019-04-18 22:43:16 +03:00
Dan Rosen
1cd8830de2 evwatch: fix race condition
There was a race between event_base_loop and evwatch_new (adding a
prepare/check watcher while iterating over the watcher list). Only
release the mutex immediately before invoking each watcher callback,
and reacquire it immediately afterwards (same as is done for normal
event handlers).
2019-04-17 15:52:05 -04:00
Azat Khuzhin
04563d59d2
Ignore build files for autotools build in subfolder too 2019-04-13 13:23:28 +03:00
Azat Khuzhin
c80f6be1e4
Merge branch '21_http_extended_method'
* 21_http_extended_method:
  Added http method extending
  http: Update allowed_methods field from 16 to 32bits.

Fixes: #327
2019-04-11 22:52:10 +03:00
Thomas Bernard
8dcb94a4ca
Added http method extending
User can define his own response method by calling
evhttp_set_ext_method_cmp() on the struct http, or
evhttp_connection_set_ext_method_cmp() on the connection.

We expose a new stucture `evhttp_ext_method` which is passed to the
callback if it's set. So any field can be modified, with some exceptions
(in evhttp_method_):

If the cmp function is set, it has the ability to modify method, and
flags. Other fields will be ignored. Flags returned are OR'd with the
current flags.

Based on changes to the #282 from: Mark Ellzey <socket@gmail.com>
2019-04-11 22:48:01 +03:00
Thomas Bernard
96e56beb94
http: Update allowed_methods field from 16 to 32bits. 2019-04-11 22:47:55 +03:00
Azat Khuzhin
799053db8a
http: replace EVHTTP_REQ_UNKNOWN_ with 0
From the server perspective the evhttp_response_phrase_internal() should
not be called with 0 before this patch, it will be called with
EVHTTP_REQ_UNKNOWN_ hence this patch should not change behavior.

Fixes: 68eb526d7b ("http: add WebDAV methods support")
Fixes: #789
Fixes: #796
Reported-by: Thomas Bernard <miniupnp@free.fr>
2019-04-10 00:51:27 +03:00
Azat Khuzhin
55f9863b18
Remove experimental note for finalizers API 2019-04-07 04:57:32 +03:00
Azat Khuzhin
428f36e5dd
https-client: do not try to free not initialized base
Otherwise:
  $ https-client --help
  Syntax:
     https-client -url <https-url> [-data data-file.bin] [-ignore-cert] [-retries num] [-timeout sec] [-crt crt]
  Example:
     https-client -url https://ip.appspot.com/
  [warn] event_base_free_: no base to free
2019-04-03 23:24:17 +03:00
Azat Khuzhin
35caeff5de
http: drop unused internal macros 2019-04-03 23:21:24 +03:00
Dan Rosen
2f184f8bbf evwatch: Add "prepare" and "check" watchers.
Adds two new callbacks: "prepare" watchers, which fire immediately
before we poll for I/O, and "check" watchers, which fire immediately
after we finish polling and before we process events. This allows other
event loops to be embedded into libevent's, and enables certain
performance monitoring.

Closes: #710
2019-04-03 12:44:50 -04:00
Azat Khuzhin
47d348a631
Disable logging for tests that assume printing warnings
To avoid possible confusion

But there is still one test that has some messages on windows:
  main/methods

Because this test needs >1 of avaiable methods, otherwise it will warn.
2019-04-03 08:00:12 +03:00
Azat Khuzhin
d4c7545017
Remove manually written nmake makefiles (cmake should be used instead)
This nmake stuff is out dated, and nobody wants to support it anyway.
2019-04-03 07:33:09 +03:00
Azat Khuzhin
93a925474d
appveyor: check intermediate powershell commands exit codes and terminate early
Otherwise build errors will be ignored, i.e. if build fails but regress
binary exists (copied from artifacts) it will be runned instead of newly
compiled.
2019-04-02 23:31:43 +03:00
Azat Khuzhin
da33f768e4
Merge branch 'fix-uchex-warnings'
There is one more report that is false positive, see [1]:
  "In bufferevent_openssl.c, pointer wm is dereferenced on line 871
before it is null checked on line 873."

  [1]: https://github.com/libevent/libevent/issues/382#issuecomment-238081938

* fix-uchex-warnings:
  evdns: do not check server_req twice
  evrpc: do not check req twice

Fixes: #382
2019-04-01 02:42:55 +03:00
Azat Khuzhin
991f0ed3d8
evdns: do not check server_req twice
Reported by µchex:
  "In evdns.c, pointer server_req is null checked on line 1289 after it
is dereferenced above. Since server_req was already null checked above
on line 1243, there is no risk of crashing and the only bug is the
redundant null check (and indentation) on line 1289.
"
2019-04-01 02:42:30 +03:00
Azat Khuzhin
7a8cc11406
evrpc: do not check req twice
reported by µchex:
  "In evrpc.c, pointer req is dereferenced on line 881 before it is null
checked on line 894."
2019-04-01 02:42:07 +03:00
Azat Khuzhin
e5b8f4c192
evdns: add DNS_OPTION_NAMESERVERS_NO_DEFAULT/EVDNS_BASE_NAMESERVERS_NO_DEFAULT
- DNS_OPTION_NAMESERVERS_NO_DEFAULT
  Do not "default" nameserver (i.e. "127.0.0.1:53") if there is no nameservers
  in resolv.conf, (iff DNS_OPTION_NAMESERVERS is set)

- EVDNS_BASE_NAMESERVERS_NO_DEFAULT
  If EVDNS_BASE_INITIALIZE_NAMESERVERS isset, do not add default
  nameserver if there are no nameservers in resolv.conf (just set
  DNS_OPTION_NAMESERVERS_NO_DEFAULT internally)

Fixes: #569
2019-04-01 02:18:59 +03:00
Azat Khuzhin
3e0dc1a6ab
evdns: add descriptions for DNS_OPTION_*/DNS_OPTIONS_ALL 2019-04-01 01:41:10 +03:00
Azat Khuzhin
2ae875ed12
Link test/regress with event_core/event_extra over event
Due to regress linked with event and event_core (both of them includes
evthread.c) there will be two different evthread_id_fn_ variables under
mingw64:
  evthread_id_fn_: &0x5294f20a8
  evthread_id_fn_: &0x4ba0030a8

And because of this evthread_use_pthreads() can/will set one copy of
variables while evthread*() functions will access another, which will
break a lot of things (for example main/del_notify test).

Fixes: #792
2019-03-25 09:54:32 +03:00
Azat Khuzhin
b8e2f01690
signal: guard __cdecl definition with #ifdef
Under mingw64:
  ../signal.c:88:0: warning: "__cdecl" redefined
   #define __cdecl

  <built-in>: note: this is the location of the previous definition

https://ci.appveyor.com/project/azat/libevent/builds/23321613#L427
2019-03-25 09:48:40 +03:00
Azat Khuzhin
8a674243b4
tinytest: fix parsing --timeout argument
Fixes: 15b2f41d ("tinytest: implement per-test timeout (via alarm() under !win32 only)")
2019-03-24 20:39:20 +03:00