4772 Commits

Author SHA1 Message Date
Azat Khuzhin
33fb0e358a test: fix unused variable in rand test (catched by newer clang) 2022-07-12 09:54:36 +03:00
Azat Khuzhin
87c016a09e ci: use ubuntu 22.04 with clang 11 for sanitizers build
There are periodically some heap-use-after-free reported in ratelim
tests by TSan, which I cannot reproduce locally and even on CI it is
flaky.

Let's try to use recent clang, maybe it fixes some issues in sanitizers.

Refs: #1206
2022-07-12 08:08:25 +03:00
Azat Khuzhin
213a822aa7 test: increase timeout significantly in dns/getaddrinfo_cancel_stress (for TSan)
Fixes: #1304
2022-07-11 22:53:57 +03:00
Azat Khuzhin
15780dd240 ci: disable broken mingw cmake builds (#1207) 2022-07-11 03:53:27 +03:00
Azat Khuzhin
c90acbb6fc Slightly adjust badges markdown in README 2022-07-11 03:51:31 +03:00
Azat Khuzhin
a3572af704 ci: fix master/upstream workflow (syntax error) 2022-07-11 03:50:16 +03:00
Azat Khuzhin
9b7b549ba0 Update CI status badge 2022-07-11 03:47:45 +03:00
Azat Khuzhin
587f26fb0c Rework CI to keep everything in one workflow (by using reusable workflow)
Right now because we have separate workflows there is no one page with
all the jobs, instead we have separate page for each workflow (linux,
windows, ...)

This is pretty inconvenient, so let's make it cleaner, and now we will
have only two:

- for pull requests
- for upstream/master
2022-07-11 03:42:50 +03:00
Azat Khuzhin
5ff98dc1f3 evdns: accept domains up to 254 long (previosly only 63 long was accepted)
Previously evdns was using HOST_NAME_MAX, and define it to 255 *only* if
it not set, however it does set on linux:

    $ egrep -r define.*HOST_NAME_MAX /usr/include/bits
    /usr/include/bits/local_lim.h:#define HOST_NAME_MAX             64
    /usr/include/bits/posix1_lim.h:#define _POSIX_HOST_NAME_MAX     255
    /usr/include/bits/confname.h:#define _SC_HOST_NAME_MAX          _SC_HOST_NAME_MAX

But 64 should be the limit of the host component, not for the whole
hostname, as also noted by @ploxiln

So use our own EVDNS_NAME_MAX const, which is set to 255.

Fixes: #1280
2022-07-10 18:10:35 +03:00
Azat Khuzhin
1933f6aadd test: make dns/getaddrinfo_cancel_stress more deterministic
Fixes: #1271
Follow-up for: 90bcf2d660b9b43cb8e747421d4938f08f935bd7
2022-07-10 16:32:36 +03:00
Azat Khuzhin
4872734277 Add a note that IOCP is experimental feature
Refs: #1228
2022-07-10 16:18:40 +03:00
Azat Khuzhin
63ef005a26 ci: drop processing "ci skip" message in commit in favor of official skip
Since [1] github actions official support skipping workflows based on
the message.

  [1]: https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
2022-07-10 15:47:00 +03:00
Azat Khuzhin
fc24a2990d ci: add ability skip specific workflow
Public CI workers has pretty high load, and sometimes you need to test
only specific workflow, i.e. windows.

So let's add ability to limit which workflow should be run.
2022-07-10 15:13:46 +03:00
Azat Khuzhin
69e9f7ee5d Initial OpenSSL 3.0 support (#1288)
* openssl-3:
  ci: use ubuntu 22.04 with OpenSSl 3.0 instead of building OpenSSL from sources
  ci: set LD_LIBRARY_PATH for openssl 3.0 build
  test: suppress warning for already defined SSL_get_peer_certificate
  autotools: print $OPENSSL_LIBS/$OPENSSL_INCS
  Suppress -Wunused-value for BIO_set_close()
  Use OPENSSL_VERSION_NUMBER over OPENSSL_VERSION_MAJOR (for compatibility)
  Attempt to add OpenSSL 3 to the Linux build matrix
  Initial OpenSSL 3.0 support
2022-07-10 13:55:32 +03:00
Azat Khuzhin
54078b30cb ci: use ubuntu 22.04 with OpenSSl 3.0 instead of building OpenSSL from sources 2022-07-10 13:11:51 +03:00
Azat Khuzhin
fb5490066d ci: set LD_LIBRARY_PATH for openssl 3.0 build
Fixes:

    /home/runner/work/libevent/libevent/build/test/.libs/regress: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
2022-07-10 12:48:04 +03:00
Azat Khuzhin
d84c88519d test: suppress warning for already defined SSL_get_peer_certificate
build report:

    [1/2] Building C object CMakeFiles/regress.dir/test/regress_mbedtls.c.o
    /src/le/libevent/test/regress_mbedtls.c:50: warning: "SSL_get_peer_certificate" redefined
       50 | #define SSL_get_peer_certificate mbedtls_ssl_get_peer_cert
          |
    In file included from /src/le/libevent/test/regress.h:139,
                     from /src/le/libevent/test/regress_mbedtls.c:35:
    /src/oss/openssl/include/openssl/ssl.h:1799: note: this is the location of the previous definition
     1799 | #   define SSL_get_peer_certificate SSL_get1_peer_certificate
          |
    [2/2] Linking C executable bin/regress

But this should be cleaned up.
2022-07-10 10:07:39 +03:00
Azat Khuzhin
a0087e2c7a autotools: print $OPENSSL_LIBS/$OPENSSL_INCS 2022-07-10 10:07:39 +03:00
Azat Khuzhin
e67085e56e Suppress -Wunused-value for BIO_set_close() 2022-07-10 10:07:39 +03:00
Azat Khuzhin
c22f275744 Use OPENSSL_VERSION_NUMBER over OPENSSL_VERSION_MAJOR (for compatibility)
Since OpenSSL 3.0 there is new OPENSSL_VERSION_MAJOR, but previous
releases does not have it.

So let's use plain old OPENSSL_VERSION_NUMBER to avoid more preprocessor
macros.
2022-07-10 10:07:39 +03:00
William Marlow
a29570a1e2 Attempt to add OpenSSL 3 to the Linux build matrix
v2: fix echo messages
v3: fix autotools build (wrong path to pkg config)
2022-07-10 10:07:25 +03:00
William Marlow
29c420c418 Initial OpenSSL 3.0 support
* Don't use deprecated functions when building against OpenSSL 3.0.
* Recognise that OpenSSL 3.0 can signal a dirty shutdown as a protocol.
  error in addition to the expected IO error produced by OpenSSL 1.1.1
* Update regress_mbedtls.c for compatibility with OpenSSL 3
2022-07-09 23:24:53 +03:00
Azat Khuzhin
20977eae0d Merge branch 'mbedtls-3'
* mbedtls-3:
  sample/ssl-client-mbedtls.c: fix for MbedTLS 3
  sample/ssl-client-mbedtls.c: break the loop on EOF
  sample/ssl-client-mbedtls.c: fix printing response in readcb
  Initial Mbed-TLS 3 support to get the GitHub Actions working again
  Support build dir of the MbedTLS
2022-07-09 23:22:00 +03:00
Azat Khuzhin
acb7ef9819 ci/macos: remove separate openssl 1.1 from build matrix
@ploxiln:

    On current homebrew, openssl@1.1 is the only openssl:

    [pierce@plo-mbp15 libevent]$ brew --prefix openssl
    /usr/local/opt/openssl@1.1
    [pierce@plo-mbp15 libevent]$ brew info openssl
    openssl@1.1: stable 1.1.1g (bottled) [keg-only]
    Cryptography and SSL/TLS Toolkit

@fanquake

    Indeed. OpenSSL 1.0 was removed from homebew in Homebrew/homebrew-core#46876. Related discussion also in Homebrew/homebrew-core#46454.
2022-07-09 21:17:06 +03:00
Azat Khuzhin
8bcbec77dd Merge branch 'fix-brew-autodetection'
* fix-brew-autodetection:
  ci: fix cmake build w/o OPENSSL_ROOT_DIR
  ci: remove separate build for BREW_AUTODETECT_OPENSSL (use it by default)
  autotools: fix autodetection of openssl location via brew
2022-07-09 21:14:16 +03:00
Azat Khuzhin
6e310e3c6c sample/ssl-client-mbedtls.c: fix for MbedTLS 3
- use build_info.h over version.h
- provide own certs

P.S. since it is simpler then adding detection of the library version
into autotools.
2022-07-09 21:11:29 +03:00
Azat Khuzhin
ce20356a32 sample/ssl-client-mbedtls.c: break the loop on EOF 2022-07-09 21:07:49 +03:00
Azat Khuzhin
fcf85e4822 sample/ssl-client-mbedtls.c: fix printing response in readcb 2022-07-09 21:07:49 +03:00
William Marlow
384c52e6be Initial Mbed-TLS 3 support to get the GitHub Actions working again
mingw has upgraded to Mbed-TLS 3.1.0, so all the mingw tests that need
Mbed-TLS currently don't work.

v2: add missing mbedtls/version.h into test/regress_mbedtls.c
v3: suppress #warning "Including compat-2.x.h is deprecated" for mbedtls/compat-2.x.h
2022-07-09 20:47:04 +03:00
Azat Khuzhin
35e12a8175 Support build dir of the MbedTLS 2022-07-09 20:47:04 +03:00
Azat Khuzhin
d881d06260 configure: fix AC_CHECK_FUNCS should use literals
Error

    configure.ac:291: warning: AC_CHECK_FUNCS(getnameinfo
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(getprotobynumber
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(getservbyname
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(inet_ntop
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(inet_pton
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
2022-07-09 20:29:09 +03:00
kenping
d96457e132 listener: Preserve last error in evconnlistener_new_bind() before close
In function evconnlistener_new_bind() after go to "err:", The
evutil_closesocket() would clear the error code( I found this under
Windows ). User can not use EVUTIL_SOCKET_ERROR() to get the
evconnlistener_new_bind()'s failing error.

I add a err_code variable to store and restore the last error code.

v2: rebased by azat to make the patch simpler
2022-07-09 20:20:58 +03:00
Azat Khuzhin
a9441ed646 ci: fix cmake build w/o OPENSSL_ROOT_DIR
cmake build rules does not have detection of OPENSSL_ROOT_DIR via brew,
so we cannot run such builds on CI.

Always set OPENSSL_ROOT_DIR for cmake.
2022-07-09 20:15:17 +03:00
Azat Khuzhin
4954b27bc0 ci: remove separate build for BREW_AUTODETECT_OPENSSL (use it by default) 2022-07-09 20:15:17 +03:00
Azat Khuzhin
8bad28d607 autotools: fix autodetection of openssl location via brew 2022-07-09 20:15:17 +03:00
Azat Khuzhin
7aeecb60c4 Merge branch 'Werror'
* Werror:
  test: ignore -Walloc-size-larger-than error for calloc() returns ENOMEM
  Fix EVBASE_ACQUIRE_LOCK/EVBASE_RELEASE_LOCK for EVENT__DISABLE_THREAD_SUPPORT
  http: suppress "flags may be used uninitialized in this function" error
  Detech -Wno-unused-functions for GCC too
  cmake: add compiler version to the status message
  Fix BEV_LOCK/BEV_UNLOCK macros for EVENT__DISABLE_THREAD_SUPPORT
  Run builds with -Werror on CI for linux
  Fix -Werror for autotools
  Add -Wundef for cmake and fix EVENT__SIZEOF_TIME_T usage
2022-07-09 18:12:07 +03:00
Azat Khuzhin
8933217698 test: ignore -Walloc-size-larger-than error for calloc() returns ENOMEM
Compiler report:

    /home/runner/work/libevent/libevent/test/regress_util.c: In function ‘test_event_calloc’:
    /home/runner/work/libevent/libevent/test/regress_util.c:1318:4: error: argument 2 value ‘9223372036854775815’ exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
      p = mm_calloc(EV_SIZE_MAX/2, EV_SIZE_MAX/2 + 8);
    In file included from /home/runner/work/libevent/libevent/test/../util-internal.h:37:0,
                     from /home/runner/work/libevent/libevent/test/regress_util.c:30:
    /usr/include/stdlib.h:541:14: note: in a call to allocation function ‘calloc’ declared here
     extern void *calloc (size_t __nmemb, size_t __size)

v2: clang on CI does not have this option
2022-07-09 17:36:13 +03:00
Azat Khuzhin
648af99afa Fix EVBASE_ACQUIRE_LOCK/EVBASE_RELEASE_LOCK for EVENT__DISABLE_THREAD_SUPPORT 2022-07-09 17:36:13 +03:00
Azat Khuzhin
c8501afc0c http: suppress "flags may be used uninitialized in this function" error
Some GCC reports [1]:

    /home/runner/work/libevent/libevent/http.c: In function ‘evhttp_make_header’:
    /home/runner/work/libevent/libevent/http.c:503:14: error: ‘flags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      ev_uint16_t flags;
                  ^~~~~
    /home/runner/work/libevent/libevent/http.c: In function ‘evhttp_get_body’:
    /home/runner/work/libevent/libevent/http.c:2354:14: error: ‘flags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      ev_uint16_t flags;
                  ^~~~~
  [1]: https://github.com/libevent/libevent/runs/7263518338?check_suite_focus=true#logs
2022-07-09 17:36:13 +03:00
Azat Khuzhin
3960449374 Detech -Wno-unused-functions for GCC too
Otherwise build fails [1]:

    /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/minheap-internal.h:64:6: error: ‘min_heap_ctor_’ defined but not used [-Werror=unused-function]
     void min_heap_ctor_(min_heap_t* s) { s->p = 0; s->n = 0; s->a = 0; }
          ^~~~~~~~~~~~~~
    In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:91:0:
    /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/bufferevent-internal.h:414:1: error: ‘bufferevent_trigger_nolock_’ defined but not used [-Werror=unused-function]
     bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options)
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:89:0:
    /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/evthread-internal.h:140:1: error: ‘EVLOCK_TRY_LOCK_’ defined but not used [-Werror=unused-function]
     EVLOCK_TRY_LOCK_(void *lock)

  [1]: https://github.com/libevent/libevent/runs/7263518180?check_suite_focus=true
2022-07-09 17:17:06 +03:00
Azat Khuzhin
92b73c7d55 cmake: add compiler version to the status message 2022-07-09 17:17:06 +03:00
Azat Khuzhin
0955071470 Fix BEV_LOCK/BEV_UNLOCK macros for EVENT__DISABLE_THREAD_SUPPORT 2022-07-09 17:17:06 +03:00
Azat Khuzhin
1915b564f3 Run builds with -Werror on CI for linux 2022-07-09 17:17:04 +03:00
Azat Khuzhin
039458892b Fix -Werror for autotools 2022-07-09 17:16:56 +03:00
Azat Khuzhin
f5ad737d73 Add -Wundef for cmake and fix EVENT__SIZEOF_TIME_T usage
Note, autotools already supports it.
2022-07-09 17:16:56 +03:00
Azat Khuzhin
1bc62ce171 https-client: fix strndup() for mingw build
Right now it still reports [1]:

    2022-07-09T10:53:05.4152800Z ../sample/https-client.c:558:43: warning: implicit declaration of function 'strndup' [-Wimplicit-function-declaration]
    2022-07-09T10:53:05.4153300Z   558 |                         char *host_ipv6 = strndup(&host[1], strlen(&host[1]) - 1);
    2022-07-09T10:53:05.4153651Z       |                                           ^~~~~~~
    2022-07-09T10:53:05.4154095Z ../sample/https-client.c:558:43: warning: incompatible implicit declaration of built-in function 'strndup' [-Wbuiltin-declaration-

  [1]: https://github.com/libevent/libevent/runs/7263194178?check_suite_focus=true
2022-07-09 14:39:32 +03:00
Azat Khuzhin
29032da661 Fix some OpenSSL 3 test issues (#1291)
These are updates to help with OpenSSL 3 compilation. I found
https://github.com/libevent/libevent/pull/1288 after I started this, but
these seem independent, and fix a different set of problems:

- First off, OpenSSL 3 does not by default allow signing with SHA1
  digests - moving this to SHA256 universally at this point seems a
  better idea than continuing to use the insecure SHA1 for older OpenSSL
  versions. This fixes X509_sign failing in regress_openssl for a number
  of tests, eg:

  ```
   regress: http/https_openssl_basic:
    FAIL ../test/regress_openssl.c:106: assert(0 != X509_sign(x509, key, EVP_sha1()))[Lost connection!] http/https_openssl_filter_basic:
    FAIL ../test/regress_openssl.c:106: assert(0 != X509_sign(x509, key, EVP_sha1()))[Lost connection!] http/https_openssl_simple:
  ...
  ```

- Secondly, when using TLS 1.3, there's no support for renegotiation, so
  for the renegotiation tests, we need to disable TLS v1.3, and expect
  to negotiate TLS 1.1 or 1.2

Fixes: #661

* upstream/pr/1291:
  OpenSSL 3 fixes: Disable TLS 1.3 when testing renegotiation support
  OpenSSL 3 fixes: use SHA256 instead of SHA1
2022-07-09 13:37:25 +03:00
William Marlow
e43376df2a Add missing strndup function on Windows to fix build on MSVC 2022
v2: Only define strndup on non-Mingw32 Windows
2022-07-09 13:16:00 +03:00
fanquake
bf3ce77f6c build: only try silence options if they exist
Otherwise GCC will warn. i.e:
```bash
  CCLD     libevent_openssl.la
cc1: note: unrecognized command-line option ‘-Wno-void-pointer-to-enum-cast’
	may have been intended to silence earlier diagnostics
  CCLD     libevent_mbedtls.la
```
2022-06-30 22:06:51 +03:00
Peter Edwards
187f6b913b OpenSSL 3 fixes: Disable TLS 1.3 when testing renegotiation support
TLS 1.3 does not support renegotation - it has been removed from the
protocol. Disable TLS 1.3 when testing this, so we negotiate an older
protocol version
2022-06-27 23:10:15 +01:00