4443 Commits

Author SHA1 Message Date
Jesse Fang
7680409aa1 simple https client example using mbedtls
Based on mbedtls's source code programs/ssl/ssl_client1.c
2020-07-22 22:52:58 +03:00
Jesse Fang
b28effa950 mbedtls based SSL implementation
prototype is libevent-2.1.11-stable libevent_openssl.c
2020-07-22 22:52:58 +03:00
fanquake
79dc8789f5
doc: fix typo in thread.h
s/evthred_use_pthreads_with_flags/evthread_use_pthreads_with_flags/
2020-07-20 21:59:10 +08:00
Azat Khuzhin
883587a9bf Merge #1048 -- append warning flags only if they are available (autotools)
* upstream/pr/1048:
  build: remove -Wstrict-aliasing as strict-aliasing is disabled
  build: move automake options into AM_INIT_AUTOMAKE call
  build: remove commented code from configure.ac
  build: use feature detection when adding compile flags
  build: add ax_check_compile_flag macro
2020-07-10 22:18:59 +03:00
fanquake
97a899d9b4
build: remove -Wstrict-aliasing as strict-aliasing is disabled
Note that -Wstrict-aliasing is also include in -Wall.
2020-07-07 13:58:47 +08:00
fanquake
28e3105072
build: move automake options into AM_INIT_AUTOMAKE call 2020-07-07 13:57:35 +08:00
fanquake
0a537b25dd
build: remove commented code from configure.ac 2020-07-07 13:57:34 +08:00
fanquake
0ea7f70744
build: use feature detection when adding compile flags
Rather than trying to detect (potentially very old) GCC versions, just
test whether the flag works with the compiler, and add it to CLFAGS if
so.

-Werror is used to convert unknown flag warnings into errors, and
prevent their addition to CLFAGS.
2020-07-07 13:57:34 +08:00
fanquake
ffb09b16ab
build: add ax_check_compile_flag macro 2020-07-07 13:57:34 +08:00
Azat Khuzhin
e9a6b12769 ci/linux: create dist artifact only if dist archive was built
Fixes: 512c88ce ("ci/linux: add dist check")
2020-07-05 14:53:08 +03:00
Azat Khuzhin
f6bfa8b3e3 Merge branch 'fix-signal-leak'
Fixes main/fork under ASAN (LSAN if to be precise)

* fix-signal-leak:
  select: requires reinit (otherwise it leaks signal handlers)
  poll: requires reinit (otherwise it leaks signal handlers)
2020-07-05 13:16:52 +03:00
Azat Khuzhin
4edfe6ad17 select: requires reinit (otherwise it leaks signal handlers)
Fixes: main/fork under SELECT with ASAN
2020-07-05 13:16:03 +03:00
Azat Khuzhin
c51c09b8ee poll: requires reinit (otherwise it leaks signal handlers)
Fixes: main/fork under POLL with ASAN
2020-07-05 13:15:37 +03:00
Azat Khuzhin
90bcf2d660 test: fix leak in dns/getaddrinfo_cancel_stress
Some requests may get response (evutil_addrinfo) from gaic_server_cb,
in case of cancel_event (10000ms) will not be fast enough.
2020-07-05 12:16:52 +03:00
Azat Khuzhin
ba19b356bf test: fix UB in evbuffer/empty_reference_prepend_buffer
UBSAN reports:
  test/regress_buffer.c:2360:2: runtime error: null pointer passed as argument 1, which is declared to never be null
  /usr/include/string.h:140:33: note: nonnull attribute specified here
2020-07-05 11:46:22 +03:00
Azat Khuzhin
9da1743b41 ci: set build type to debug with sanitizers 2020-07-05 11:21:04 +03:00
Azat Khuzhin
7b9ba3b717 test: really disable bufferevent_pair_release_lock under ASAN (and fix gcc) 2020-07-05 11:19:10 +03:00
Azat Khuzhin
e2f938c04f test-closed: fix leak 2020-07-05 11:08:05 +03:00
Pierce Lopez
b6497fa148 build: do not disable deprecation warnings on macOS
this was for using openssl-0.9.8 included in macOS 10.7 - 10.12,
but it is long since time you really should not use that openssl
2020-07-04 16:01:41 -04:00
Azat Khuzhin
9ca7a492f5 Merge #1046 -- build: misc configure changes
* upstream/pr/1046:
  build: consolidate darwin compile flag additions in configure
  build: consistently use dnl for comments in configure.ac
2020-07-03 09:27:20 +03:00
Azat Khuzhin
1cea01d6d5 Add abi-check report into artifacts 2020-06-28 17:10:03 +03:00
fanquake
e05ee6d3b5
build: consolidate darwin compile flag additions in configure
This is mostly move-only, apart from some changes to comments.
2020-06-28 19:34:14 +08:00
fanquake
8ac10b6bf7
build: consistently use dnl for comments in configure.ac 2020-06-28 19:34:10 +08:00
Azat Khuzhin
0ac3cfc0b7 test: add getaddrinfo(AI_ADDRCONFIG) test (off by default) 2020-06-26 11:32:59 +03:00
fanquake
ff4ec5fdb0
build: remove duplicate -Wredundant-decls 2020-06-26 14:35:41 +08:00
Azat Khuzhin
d5aa783bb2 Merge branch 'tests-under-sanitizers'
* tests-under-sanitizers:
  test: fix memory leaks for https (add BEV_OPT_CLOSE_ON_FREE)
  test: "fix" (with a quirk) leak in ssl/bufferevent_wm (w/o defer callbacks)
  test: disable bufferevent/bufferevent_pair_release_lock under ASAN (too tricky)
  test: detect test failures if atexit handler calls _exit(!0) (sanitizers)
  Add LSAN suppressions (for OpenSSL temporary quirk)
  Add TSAN suppressions
  ci: run tests under sanitizers

Fixes: #955
2020-06-25 23:16:16 +03:00
Azat Khuzhin
ec94a6bb3f test: fix memory leaks for https (add BEV_OPT_CLOSE_ON_FREE)
- http/https_filter_basic
- http/https_filter_chunk_out
2020-06-25 22:57:53 +03:00
Azat Khuzhin
cdbb2373f4 test: "fix" (with a quirk) leak in ssl/bufferevent_wm (w/o defer callbacks) 2020-06-25 22:57:40 +03:00
Azat Khuzhin
3b13a64789 test: disable bufferevent/bufferevent_pair_release_lock under ASAN (too tricky)
And cannot be suppressed with suppressions due to setup routines.
2020-06-25 22:57:40 +03:00
Azat Khuzhin
6754740f15 test: detect test failures if atexit handler calls _exit(!0) (sanitizers)
tinytest uses another way of detecting test failures, it uses pipe
between child and parent, and if the test function in child returns OK
it writes OK flag into pipe, and reads it in parent.

However sanitizers uses atexit handlers to detect leaks, and this will
not detect failures in case of exit() will be called from the atexit
handlers, fix this by checking status after waitpid().
2020-06-25 22:57:40 +03:00
Azat Khuzhin
3fec471c32 Add LSAN suppressions (for OpenSSL temporary quirk) 2020-06-25 22:57:40 +03:00
Azat Khuzhin
b90b19250a Add TSAN suppressions 2020-06-25 22:57:40 +03:00
Azat Khuzhin
0db4e1c46c ci: run tests under sanitizers
Added:
- ASAN
- TSAN
- UBSAN

And disable some tests that are know to have leaks.
2020-06-25 22:51:06 +03:00
Enji Cooper
46c9ead0eb Make all classes Entry, Struct, etc) new-style classes
This allows the object methods to be properly inherited and called via
`super(..)`, addressing breakage with python 2.x, introduced in
cfcc093606e747a5d250787012bac0b149c60d6d.

Fixes #1042.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2020-06-25 08:11:00 -07:00
Azat Khuzhin
c424594b04 evdns: do not pass NULL to memcpy() in evdns_server_request_format_response()
In case of OPT pseudo-RR `class` field is treated as a requestor's UDP
payload size, and class will have 512 (DNS_MAX_UDP_SIZE), and data is
NULL:

  (gdb) p *item
  $4 = {
    next = 0x0,
    name = 0x602000000130 "",
    type = 41,
    class = 512,
    ttl = 0,
    is_name = 0 '\000',
    datalen = 0,
    data = 0x0
  }

And UBSAN will reports:

  ../evdns.c:2493:5: runtime error: null pointer passed as argument 2, which is declared to never be null
      #0 0x7ffff70b65bb in evdns_server_request_format_response ../evdns.c:2493
      #1 0x7ffff70b706b in evdns_server_request_respond ../evdns.c:2529
      #2 0x5555557975ab in regress_dns_server_cb ../test/regress_testutils.c:263
      #3 0x7ffff70a8489 in request_parse ../evdns.c:1576
      #4 0x7ffff70aa445 in server_udp_port_read ../evdns.c:1726
      #5 0x7ffff70ac5cc in server_port_ready_callback ../evdns.c:1849
      #6 0x7ffff6d3054c in event_persist_closure ../event.c:1645
      #7 0x7ffff6d311cd in event_process_active_single_queue ../event.c:1704
      #8 0x7ffff6d33258 in event_process_active ../event.c:1805
      #9 0x7ffff6d361b5 in event_base_loop ../event.c:2047
      #10 0x7ffff6d334ac in event_base_dispatch ../event.c:1839
      #11 0x555555739df2 in test_edns ../test/regress_dns.c:2639
      #12 0x5555557b9e96 in testcase_run_bare_ ../test/tinytest.c:173
      #13 0x5555557ba8f0 in testcase_run_one ../test/tinytest.c:333
      #14 0x5555557bc9a0 in tinytest_main ../test/tinytest.c:527
      #15 0x555555787faa in main ../test/regress_main.c:528
      #16 0x7ffff606c001 in __libc_start_main (/usr/lib/libc.so.6+0x27001)
      #17 0x55555569436d in _start (/src/le/libevent/.cmake-debug/bin/regress+0x14036d)
2020-06-25 10:22:24 +03:00
Azat Khuzhin
a0c642ac04 buffer: do not pass NULL to memcpy() from evbuffer_pullup()
UBSAN reports:

  evbuffer/remove_buffer_with_empty3: ../buffer.c:1443:3: runtime error: null pointer passed as argument 2, which is declared to never be null
      #0 0x7ffff6cd0410 in evbuffer_pullup ../buffer.c:1443
      #1 0x5555556d68b9 in test_evbuffer_remove_buffer_with_empty3 ../test/regress_buffer.c:408
      #2 0x5555557b95ee in testcase_run_bare_ ../test/tinytest.c:173
      #3 0x5555557ba048 in testcase_run_one ../test/tinytest.c:333
      #4 0x5555557bc0f8 in tinytest_main ../test/tinytest.c:527
      #5 0x555555787702 in main ../test/regress_main.c:528
      #6 0x7ffff606c001 in __libc_start_main (/usr/lib/libc.so.6+0x27001)
      #7 0x55555569436d in _start (/src/le/libevent/.cmake-debug/bin/regress+0x14036d)
2020-06-25 10:15:01 +03:00
Azat Khuzhin
6f152befb4 test: do not pass NULL to memcmp() in evbuffer_datacmp() helper
Fixes:
  runtime error: null pointer passed as argument 2, which is declared to never be null
2020-06-25 09:59:35 +03:00
Azat Khuzhin
37dbb35080 http: fix undefined-shift in EVUTIL_IS*_ helpers
evutil.c:2559:1: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
    #0 0x4f2be0 in EVUTIL_ISXDIGIT_ libevent/evutil.c:2559:1
    #1 0x4bd689 in regname_ok libevent/http.c:4838:7
    #2 0x4bc16b in parse_authority libevent/http.c:4958:9
    #3 0x4bb8b5 in evhttp_uri_parse_with_flags libevent/http.c:5103:7
    #4 0x4bb762 in evhttp_uri_parse libevent/http.c:5050:9
    #5 0x4b8f41 in evhttp_parse_query_impl libevent/http.c:3505:9
    #6 0x4b8ed7 in evhttp_parse_query libevent/http.c:3569:9

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23291
Report: https://oss-fuzz.com/testcase-detail/5670743106125824
2020-06-25 09:51:20 +03:00
Azat Khuzhin
4528d8e987 Check error code of evhttp_add_header_internal() in evhttp_parse_query_impl() 2020-06-25 09:41:54 +03:00
fanquake
45c3fc29fb
wepoll: use lower-cased windows headers
This matches their use throughout the rest of the project, and fixes the
build when you are cross-compiling on Linux using mingw-w64. i.e:

  CC       epoll.lo
  CC       wepoll.lo
  CC       signal.lo
wepoll.c:138:10: fatal error: WS2tcpip.h: No such file or directory
 #include <WS2tcpip.h>
          ^~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:1918: wepoll.lo] Error 1
2020-06-22 19:40:06 +08:00
Paul Osborne
26d5ff457c cmake: avoid problems from use of CMAKE_USE_PTHREADS_INIT
In some CMake integrations, portions of the toolchain may end up
defining CMAKE_USE_PTHREADS_INIT even when EVENT__DISABLE_THREAD_SUPPORT
is set for libevent.  Modify the build to not rely on this side effect
of find_package(Threads, ...) [which could be done elsewhere] but instead
to use EVENT__HAVE_PTHREADS which is defined only on the desired codepath.

Without this change, affected builds fail as a result of event_pthreads source
files being built but with build defines which cause the build to fail.

Signed-off-by: Paul Osborne <paul.osborne@smartthings.com>
2020-06-18 15:47:14 +00:00
okhowang(王沛文)
efbe563b4e recreate socket when udp failed 2020-06-08 20:20:20 +08:00
Azat Khuzhin
2aaa7358a1 test/regress_http: remove second ARRAY_SIZE macros 2020-06-02 10:12:20 +03:00
Azat Khuzhin
8b5a4d61f6 test/regress_testutils: use inet_addr() 2020-06-02 10:01:31 +03:00
Azat Khuzhin
271c5aaa81 test/regress_dns: use tt_int_op() over tt_assert() in assert_request_results() 2020-06-02 10:00:38 +03:00
seleznevae
83c58d4985 evdns: Add support for setting maximum UDP DNS message size.
Added new option `edns-udp-size` for evdns_base which allows
to control maximum allowed size of UDP DNS messages. This
maximum size is passed to the DNS server via edns mechanism.
2020-05-31 19:59:49 +03:00
yuangongji
c753ae876e CI: catch failures and retry 2020-05-28 20:10:47 +08:00
yuangongji
a9aa2b3607 remove FindGit.cmake, improve git describe command 2020-05-28 20:10:47 +08:00
Azat Khuzhin
89d313b14d checkpatch.sh: fix clang-format-diff usage
- strip 1 path component
- it does not accept file name anymore, only stdin

Refs: #1029
2020-05-27 20:36:38 +03:00
Azat Khuzhin
8209a623ad checkpatch.sh: fix usage
Refs: #1029
2020-05-27 20:36:28 +03:00