4908 Commits

Author SHA1 Message Date
Azat Khuzhin
13f5552336 test: add missing include of arpa/inet.h for ntohs in regress_ws.c
This will fix one warning in FreeBSD
2023-05-14 22:31:02 +02:00
Azat Khuzhin
1f006637ec Merge branch 'build/osx-fixes'
* build/osx-fixes:
  Suppress -Wmacro-redefined for htonll/ntohll in OSX
  Fix -Wtautological-constant-out-of-range-compare in regress_http under OSX
2023-05-14 22:03:26 +02:00
Azat Khuzhin
6eba967e1c Suppress -Wmacro-redefined for htonll/ntohll in OSX
OSX:

    test/regress_ws.c:61:9: warning: 'htonll' macro redefined [-Wmacro-redefined]
    #define htonll(x)    \
            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_endian.h:141:9: note: previous definition is here
    #define htonll(x)       __DARWIN_OSSwapInt64(x)
            ^
    test/regress_ws.c:65:9: warning: 'ntohll' macro redefined [-Wmacro-redefined]
    #define ntohll(x) htonll(x)
            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_endian.h:140:9: note: previous definition is here
    #define ntohll(x)       __DARWIN_OSSwapInt64(x)
            ^
2023-05-14 22:01:18 +02:00
Azat Khuzhin
5f1fc92b13 Fix -Wtautological-constant-out-of-range-compare in regress_http under OSX
compiler warning:

    test/regress_http.c:968:38: warning: result of comparison of constant 65536 with expression of type 'enum evhttp_cmd_type' is always true [-Wtautological-constant-out-of-range-compare]
            if (evhttp_request_get_command(req) != EVHTTP_REQ_CUSTOM) {
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~
2023-05-14 21:55:43 +02:00
Dmitry Antipov
d19690980d Silence weird GCC warning about an uninitialized variable
For the CMake release build with -DEVENT__ENABLE_GCC_WARNINGS=ON
and -DEVENT__DISABLE_MM_REPLACEMENT=ON, GCC version 11 and 12 may
complain about possibly uninitialized variable:

In function ‘event_debug_assert_not_added_’,
    inlined from ‘event_assign’ at event.c:2184:2,
    inlined from ‘event_new’ at event.c:2276:6:
cc1: error: ‘ev’ may be used uninitialized [-Werror=maybe-uninitialized]
event.c: In function ‘event_new’:
event.c:361:13: note: by argument 1 of type ‘const struct event *’ to  event_debug_assert_not_added_.part.0’ declared here
  361 | static void event_debug_assert_not_added_(const struct event *ev)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This warning is most likely a false positive and can be silenced
by explicitly disabling inlining for 'event_assign()'.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2023-05-14 20:42:19 +02:00
Azat Khuzhin
73037f88f9 Ignore any archives (since you may use separate build dir for 'make dist') 2023-05-14 20:32:50 +02:00
Azat Khuzhin
e8cbe7b6e1 Merge branch 'ssl/fix-partial-read' - #1451
* ssl/fix-partial-read:
  ssl: do not triger EOF if some data had been successfully read
  ssl: rename err_is_ok to handshake_is_ok (internal API)
2023-05-14 20:04:44 +02:00
Azat Khuzhin
7652cf4068 ssl: do not triger EOF if some data had been successfully read
Previously in case when evbuffer_reserve_space() returns > 1, but
it was able to read only 1 IO vector, it will try to read the next one,
got 0 (EOF for mbedTLS or SSL_ERROR_ZERO_RETURN for OpenSSL) and will
trigger EOF, while instead, it should trigger EV_READ w/o EOF and only
after EOF.
2023-05-14 16:53:13 +02:00
Azat Khuzhin
6375dcb46d ssl: rename err_is_ok to handshake_is_ok (internal API) 2023-05-14 16:49:18 +02:00
liaotonglang
d06e573c60 style fix: use tab for indent 2023-05-05 22:42:43 +02:00
fanquake
bdb343e180 ci: use newer actions/x versions for master jobs
Now that the jobs are running again, a number of deprecation warnings
have surfaced
https://github.com/libevent/libevent/actions/runs/4876367881:
```bash
Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2.0.0.
```

Looks like the most straightforward thing todo here is just use the
newer version of the checkout action.

Also move to the v1 tag for the coveralls job, rather than a pinned,
much older version (the latest release is 1.2.5, https://github.com/coverallsapp/github-action/releases).

Same again for actions/cache.
2023-05-04 21:21:40 +02:00
fanquake
211736697b ci: use OpenBSD 7.2 over 7.1
In the most recent CI run, all the OpenBSD CI jobs failed, i.e
https://github.com/libevent/libevent/actions/runs/4876367885/jobs/8699759831,
this seems to be due to the fact that packages for 7.1 have been removed
from https://cdn.openbsd.org/pub/OpenBSD/ (only has 7.2 & 7.3):
```bash
  Config file: openbsd-7.1.conf
  https://cdn.openbsd.org/pub/OpenBSD/7.1/packages/amd64/: no such dir
  Can't find rsync-3.2.3p0
  Couldn't install rsync-3.2.3p0
  exec shell: bash run.sh showDebugInfo
```

Switch to using 7.2, which is available, so that the CI will run.
2023-05-04 21:20:23 +02:00
fanquake
60ad22d47d actions: use supported version of Ubuntu
It looks like these jobs are failing to run, because support for
ubuntu-18.04 has been removed entirely, see:
https://github.com/actions/runner-images/issues/6002.

Migrate to ubuntu-20.04.
2023-05-03 22:43:17 +02:00
fanquake
75208132d5
doc: minor cleanups following #1441 (#1442)
Also fixes 1 broken link (apologies).
2023-04-20 23:33:22 +03:00
Azat Khuzhin
612a74c766
Merge pull request #1441 from fanquake/autoconf_doc_updates
doc: minor autoconf/formatting improvements
2023-04-17 21:19:58 +02:00
fanquake
ac69410e1b
doc: mark Autotools as deprecated in building.md
Re-arrange so CMake is mentioned first.
Formatting improvements.
2023-04-17 14:42:59 +01:00
fanquake
2470b37bd1
doc: move autoconf link in readme to autoconf section. 2023-04-17 14:22:30 +01:00
lilinjie
4c993a0e7b
Fix typo in changelog (#1438) 2023-04-11 06:44:37 +02:00
Azat Khuzhin
f747a7b93b Prohibit VLA in autotools too 2023-04-04 22:19:07 +02:00
Azat Khuzhin
f04d90b121 Fix building with -Wstack-protector due to VLA and fobid them
It is not a thankless task to fix such issues on and on, let's just
prohibit this cases, and our build with -Werror on CI will show new
issues from now on.

Fixes: #1434
2023-04-04 22:17:14 +02:00
fanquake
1878232bd5 build: split kqueue warning message into cross-compile and apple
This is output when compiling (natively) on macOS systems, which is
confusing, because no cross-compilation is involved.

Split the message into separate cases.
2023-04-04 22:04:17 +02:00
zhenhaonong
fc568ff045 Deal with partial writes on SSL write
SSL write may do partial writes in some cases. For example, document
of mbedtls_ssl_write says:
  If the return value is non-negative but less than length, the function
  must be called again with updated arguments: buf + ret, len - ret
  (if ret is the return value) until it returns a value equal to the
  last 'len' argument.

In case of partial writes, we should continue writing the same chain of
buffer, not the next chain.
2023-03-29 06:19:10 +02:00
Liao Tonglang
9203d98ff8
http: style fix: use space between arguments list (#1435) 2023-03-26 22:35:00 +02:00
Azat Khuzhin
6e1826dd77 ci: fix typo in yaml for cifuzz
Follow-up for: #1431
2023-03-08 21:34:37 +01:00
Azat Khuzhin
606056d6e7 ci: switch to ubuntu 20.04
github action reports "internal error" for builds on ubuntu 18.04:

    linux-cmake-job (ubuntu-18.04, COMPILER_CLANG)
    This is a scheduled Ubuntu-18.04 brownout. The Ubuntu-18.04 environment is deprecated and will be removed on April 1st, 2023. For more details, see https://github.com/actions/runner-images/issues/6002

    linux-cmake-job (ubuntu-18.04, COMPILER_CLANG)
    GitHub Actions has encountered an internal error when running your job.
2023-03-07 06:15:33 +01:00
Diogo Teles Sant'Anna
99a4b1a786 ci: set minimal permissions on GitHub Actions
Change made by setting top-level read-only permisisons, and any
other necessary permissions set as job-level.

Closes #1421

Signed-off-by: Diogo Teles Sant'Anna <diogoteles@google.com>
2023-03-06 21:18:59 +01:00
Liao Tonglang
6bfa580559
http: Reduce times of checking if response has body (#1395)
Use a variable 'need_body' to store the result of
evhttp_response_needs_body(), then use the variable instead of call the function again.
2023-03-05 16:59:21 +01:00
Michael Ford
185e2f009b
build: improve mbedtls searching on macOS with brew for cmake (#1419)
This just copies the same logic used to find OpenSSL on macOS using homebrew, for finding mbedtls via brew. Without it, the build will fail out the box with a brew installed mbedtls.
2023-03-05 16:58:22 +01:00
Kurt Roeckx
4e6375e84c
Always have evutil_secure_rng_add_bytes available (#1427)
When libevent doesn't provide random the arc4 function, but they come from libc, there is no need to call this function, so make it do nothing.

Fixes: #1393
2023-03-05 16:56:56 +01:00
Zhipeng Xue
3a0cf34ba5 ws-chat-server: fix potential resource leak 2023-03-05 16:48:27 +01:00
Zhipeng Xue
bac9d10a6d
Fix potential null dereference in http-server (#1430)
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2023-03-04 22:13:54 +01:00
Zhipeng Xue
fa05966d74
test: fix potential null dereference in https_bind_ssl_bevcb (#1428)
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2023-03-04 22:12:04 +01:00
Cœur
557990cad3 Optimize arc4random_uniform() (by syncing with OpenBSD implementation)
1. In d4de062, in Feb 2010, libevent adopted OpenBSD implementation of
   arc4random_uniform.
2. In
   728918cba9,
   in Jun 2012, OpenBSD improved their implementation to be faster, by
   changing arc4random_uniform() to calculate ``2**32 % upper_bound'' as
   ``-upper_bound % upper_bound''.

Alternatively we can simply remove arc4random_uniform() since it is not
used by libevent anyway, but let's just sync the header for now.
2023-03-02 07:51:14 +01:00
Cœur
e96e98aea5 evdns: fix "Branch condition evaluates to a garbage value" in reply_parse 2023-03-02 07:41:08 +01:00
Cœur
3bcc92cf59 Fix the value is never actually read from 'argument' in evhttp_parse_query_impl()
Although the value stored to 'argument' is used in the enclosing
expression, the value is never actually read from 'argument'
2023-03-02 07:32:17 +01:00
Cœur
b84fee24ab Fix "Value stored to 'a' is never read" in SHA1Transform()
Using same fix as used in android [1].

  [1]: android.googlesource.com/platform/dalvik/+/android-4.4.2_r2/libdex/sha1.cpp#193
2023-03-02 07:29:18 +01:00
Azat Khuzhin
bcefdbc67a
Merge pull request #1418 from fanquake/use_fortify_source_3
build: use FORTIFY_SOURCE=3 in hardening option
2023-02-14 09:56:03 +01:00
fanquake
e89ddd405b
build: use FORTIFY_SOURCE=3 in autotools build 2023-02-13 16:06:29 +00:00
fanquake
38cd76f09c
build: use FORTIFY_SOURCE=3 in CMake build 2023-02-13 16:05:58 +00:00
Azat Khuzhin
28c28f075b
Merge pull request #1414 from azat/build/deprecate-autotools
Deprecate autotools build
2023-02-13 08:09:21 +01:00
Azat Khuzhin
1df2a5a69e test: enable allocator_may_return_null=1 for calloc with ENOMEM test 2023-02-12 21:55:40 +01:00
Azat Khuzhin
207ea62bf9 test: handle -v as --verbose for regress 2023-02-12 21:55:40 +01:00
Azat Khuzhin
0ea2058252 test: add del_wait/del_notify tests for windows
Test manually, since CI is too slow
2023-02-12 21:54:45 +01:00
Azat Khuzhin
c437b84adb Remove extra builds for autotools on CI
We have almost the same matrix for cmake and autotools, but autotools is
considered to be deprecated from now on, plus our CI takes too much
time, especially non-linux, since we are using public infrastucture.

So let's remove extra builds.
2023-02-12 16:30:03 +01:00
Azat Khuzhin
f7e39d2e9b ci: bump cache and checkout plugins 2023-02-12 16:30:03 +01:00
Azat Khuzhin
b5a6940df2 ci: fix paths-ignore 2023-02-12 16:30:03 +01:00
Azat Khuzhin
7e6d9b0b17 .github/workflows/build.yml: remove trailing whitespaces 2023-02-12 16:30:03 +01:00
Azat Khuzhin
866b751b71 Deprecate autotools build 2023-02-12 16:30:03 +01:00
Edoardo Lolletti
765fb4108d
Fix compilation on non recent windows SDKs (#1399)
In commit f8bb9d8 the header stringapiset.h was included, very likely because the user who made the change saw that the funciton WideCharToMultiByte is "declared" in there.
That header tho is a recent addition to the windows headers added in the last years in an attempt from microsoft to split the windows.h header in multiple files, so the inclusion fails when the library is not built with the latest visual studio using the latest windows 10 sdk.
That inclusion can be safely removed as in any case the function WideCharToMultiByte was already included by the windows.h header that is included few lines below.
2023-02-12 16:19:35 +01:00
Azat Khuzhin
61de8a07c5
test: fix leaks in bufferevent_pair_release_lock (#1413) 2023-02-12 15:47:16 +01:00