1438 Commits

Author SHA1 Message Date
icy17
d1a90d09dc tests: Fix potential NULL pointer dereference 2024-08-12 10:02:04 +02:00
Dmitry Ilyin
00c94beaf0 ws: allow Upgrade in Connection header anywhere
This will make it work for Firefox, which uses "Connection: keep-alive, Upgrade"
Reimplemented our own evutil_ascii_strcasestr function (same as
non-portable strcasestr)
2024-07-27 09:18:10 +03:00
Cœur
9848df54cc
http: disallow empty header names (#1690)
In theory, we could be more strict, since there is only a subset of allowed characters:
> ```
> tchar          = "!" / "#" / "$" / "%" / "&" / "'" / "*"
>                 / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
>                 / DIGIT / ALPHA
>                 ; any VCHAR, except delimiters
> ```

But I'd skip such verification, unless there is a legitimate interest (versus performances).

Fixes: #1686
2024-07-26 22:53:30 +02:00
Cœur
5485887c47 Check against EVUTIL_INVALID_SOCKET 2024-07-08 10:20:47 +02:00
icy17
3f799ab675 test/test-changelist: add proper exit path 2024-07-08 10:20:47 +02:00
icy17
6f9f2f3a09 test/test-changelist.c: fix potential NULL pointer dereference 2024-07-08 10:19:35 +02:00
Azat Khuzhin
66428fb969 test-closed: fix -Werror=maybe-uninitialized
Follow-up for: https://github.com/libevent/libevent/pull/1680
2024-07-08 10:15:29 +02:00
Cœur
272bd7ddf0
Fix potential Null pointer dereference in test-closed.c (#1680)
* Fix potential Null pointer dereference in test-closed.c

* add err path

* code review: goto err after evutil_socketpair failure

* code review: goto err for event_config_new failure

---------

Co-authored-by: icy17 <1061499390@qq.com>
2024-07-08 10:13:08 +02:00
Cœur
2bc831c889
Fix potential Null pointer dereference in test-time.c (#1681)
* Fix potential Null pointer dereference in test-time.c

* add err path

* code review: free events before base

---------

Co-authored-by: icy17 <1061499390@qq.com>
2024-07-08 10:08:58 +02:00
Cœur
8dd92069d6
Fix potential Null pointer dereference in bench_httpclient.c (#1676)
Co-authored-by: icy17 <1061499390@qq.com>
2024-06-23 21:15:23 +02:00
Cœur
5d830362dd
Fix potential Null pointer dereference in regress_dns.c (#1675)
Co-authored-by: icy17 <1061499390@qq.com>
2024-06-23 21:12:39 +02:00
Cœur
6d8c38afe7 Reducing the number of mingw warnings 2024-06-02 18:21:49 +03:00
Azat Khuzhin
13678f370c
gcc: fix some compiler errors from the new GCC (#1658)
gcc: fix some compiler errors from the new GCC
2024-06-02 00:53:58 +03:00
fanquake
f5b6104319 test: use evutil_timerclear over timerclear 2024-06-01 19:33:53 +03:00
Cœur
b202a72be4 temp size assert for #1632 2024-06-01 19:29:34 +03:00
Andy Pan
e58f1fa615 Fix the -Wint-conversion
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-06-01 18:24:43 +02:00
Andy Pan
ceb6551fa2 gcc: fix the -Wincompatible-pointer-types errors
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-06-01 18:24:43 +02:00
Andy Pan
7a9458c09b
Don't try to set SO_REUSEADDR and SO_REUSEPORT on Unix sockets (#1625) 2024-05-20 11:17:45 +02:00
Azat Khuzhin
0f51ba669a test: mark http/timeout_read_server as retriable 2024-05-06 09:13:00 +02:00
Azat Khuzhin
ba97d94738 test: reset some static vars to avoid affecting other tests 2024-05-06 09:13:00 +02:00
Azat Khuzhin
479b5ed6f4 test: fix printing number of retries for FAILED message 2024-05-06 09:13:00 +02:00
Azat Khuzhin
d538f41f0a test: add debugging for bufferevent/bufferevent_connect_fail_eventcb* 2024-05-06 09:13:00 +02:00
Azat Khuzhin
2d4d1747e9 test: suppress logging for buffer/add_file_leak1
Warnings from this test should be ignored:

    [warn] evbuffer_file_segment_materialize: mmap(5, 0, 0) failed: Invalid argument
2024-05-06 09:13:00 +02:00
Azat Khuzhin
93a76aa275 test: add proper message in case of test failure
Right now it is impossible to understand what had been failed, but
after:

    $ regress thread/conditions_simple
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING thread/conditions_simple (attempts left 2, delay 1 sec)]
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING thread/conditions_simple (attempts left 1, delay 1 sec)]
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING thread/conditions_simple (attempts left 0, delay 1 sec)]
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [conditions_simple FAILED]

      [FAILED thread/conditions_simple (attempts made -1)]
    1/1 TESTS FAILED. (0 skipped)
2024-05-05 20:22:23 +02:00
Azat Khuzhin
d5745413cc test: fix RETRYING message (add missing group prefix)
Before:

    $ regress thread/conditions_simple
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING conditions_simple (attempts left 2, delay 1 sec)]

After:

    $ regress thread/conditions_simple
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING thread/conditions_simple (attempts left 2, delay 1 sec)]
2024-05-05 20:21:58 +02:00
Cœur
eec47a6710
Fix typos (#1634) 2024-04-30 09:59:58 +02:00
Andy Pan
aef201a9fc
Change ident for EVFILT_USER to 0 and add a test (#1582)
Conventionally, ident for EVFILT_USER is set to 0 to avoid
collision of file descriptors, which is what other renowned
networking frameworks like netty(java), mio(rust), gnet(go),
swift-nio(swift), etc. do currently.

Co-authored-by: Azat Khuzhin <azat@libevent.org>
2024-04-29 07:35:33 +02:00
dockercui
147298a2d1 Fix some comments
Signed-off-by: dockercui <dockercui@aliyun.com>
2024-04-24 08:27:12 +02:00
williammuji
9de85b5834 fix WSOptions enum value and extended payload length bug 2024-04-15 10:31:04 +03:00
icy17
6e390911d0 Fix potential Null pointer dereference in regress_buffer.c 2024-04-15 10:26:46 +03:00
icy17
74217832a8 Fix potential Null pointer dereference in regress.c 2024-04-15 10:26:11 +03:00
icy17
d6e8835256 Fix potential Null pointer dereference in regress_et.c 2024-04-15 10:17:08 +03:00
icy17
d45dca4373 Fix potential Null pointer dereference in regress_thread.c 2024-04-15 10:16:26 +03:00
icy17
2bdf17370c Fix potential Null pointer dereference in regress_finalize.c 2024-04-15 10:08:00 +03:00
icy17
17796a2d8a Fix potential Null pointer dereference in regress_http.c 2024-04-15 10:06:42 +03:00
icy17
f9526e13ce Fix potential NULL pointer dereference in regress_bufferevent.c 2024-04-15 10:05:32 +03:00
icy17
fc48803db4
Fix potential Null pointer dereference in regress_zlib.c (#1597)
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2024-04-15 10:02:27 +03:00
Azat Khuzhin
539f73e319 Fix leak in evbuffer_add_file() on empty files
Found by oss-fuzz, after coverage had been improved in google/oss-fuzz#11257
v2: adjust test
v3: fix for windows (_get_osfhandle() crashes when called on closed fd)
v4: fix for EVENT__DISABLE_MM_REPLACEMENT
2024-03-12 09:29:47 +01:00
tgolang
9c8860ec6c chore: remove repetitive words
Signed-off-by: tgolang <seekseat@aliyun.com>
2024-03-11 09:18:25 +01:00
Andy Pan
e66df92cfc
Accept SOCK_NONBLOCK/SOCK_CLOEXEC in type argument of socketpair (#1567)
Setting `SOCK_NONBLOCK` and `SOCK_CLOEXEC` in the `type` argument of `socketpair()` is widely supported across UNIX-like OS: Linux, *BSD, Solaris, etc., as is the `socket()`. This will conserve several extra system calls, we should use it where available.

### References

- [socketpair(2) on Linux](https://man7.org/linux/man-pages/man2/socketpair.2.html#HISTORY)
- [socketpair(2) on FreeBSD](https://man.freebsd.org/cgi/man.cgi?query=socketpair&sektion=2#DESCRIPTION)
- [socketpair(2) on DragonFly](https://man.dragonflybsd.org/?command=socketpair&section=2)
- [socketpair(2) on NetBSD](https://man.netbsd.org/socketpair.2#DESCRIPTION)
- [socketpair(2) on OpenBSD](https://man.openbsd.org/socketpair.2)
- [socketpair(3C) on Solaris](https://docs.oracle.com/cd/E88353_01/html/E37843/socketpair-3c.html)

Changelog:
- Set SOCK_NONBLOCK and SOCK_CLOEXEC in the type argument of socketpair
- Avoid EPROTOTYPE on macOS and OpenBSD
- Eliminate the warnings about unused variables
- Add some comments
2024-03-07 09:19:11 +01:00
Azat Khuzhin
e4b8732701 Fix integer-overflow in ev_token_bucket_cfg_new
Found by oss-fuzz, after coverage had been improved in https://github.com/google/oss-fuzz/pull/11257

v2: better check (found by CI for windows)
2024-03-03 16:25:08 +01:00
Azat Khuzhin
c4fb0f7603 Fix divide-by-zero in ev_token_bucket_get_tick_
Found by oss-fuzz, after coverage had been improved in https://github.com/google/oss-fuzz/pull/11257
2024-02-20 08:58:04 +01:00
Azat Khuzhin
0dbd3eb3c9 tests: add test for EV_SIGNAL with timeout
Refs: https://github.com/libevent/libevent-book/issues/12
2024-02-19 22:07:32 +01:00
Ramon Ortega de Voor
ed35b30feb Fix two compiler errors for unused variable and undefined function
In buffer.c a variable "flags" and a label "done" are defined but
never used if "EVENT__HAVEMMAP" is not defined.

The code does not work on platforms which do not provide
the function `socketpair()`. Introduce EVENT__HAVE_SOCKETPAIR flag
which determines if `socketpair()` or `evutil_ersatz_socketpair()`
is used.
2024-02-19 08:19:24 +01:00
Azat Khuzhin
87cdcc1868 http: change error for corrupted requests to 400 Bad Request
Previously it was 413 Request Entity Too Large, which was odd.
2024-02-18 17:02:45 +01:00
Azat Khuzhin
e60d039ddf tests: add a test for malformed chunks
v2: fix test for win32 (and it more correct in general)
2024-02-18 17:02:32 +01:00
Sam James
4c38de8cb3
Fix -Walloc-size (#1526)
Co-authored-by: Azat Khuzhin <azat@libevent.org>
2023-11-26 21:52:32 +01:00
Azat Khuzhin
c15ba75d18 Merge branch 'evbuffer_add_reference_with_offset' - #1513
* evbuffer_add_reference_with_offset:
  Add a comment for evbuffer_ref_cleanup_cb
  tests: simplify test_evbuffer_add_reference_with_offset
  Add function evbuffer_add_reference_with_offset()
2023-09-22 09:35:42 +02:00
Azat Khuzhin
d9780cf96a Fix -Wsingle-bit-bitfield-constant-conversion warning in clang 16
report:

    /src/le/libevent/sample/becat.c:304:29: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
                            case 'k': o.extra.keep   = 1; break;
2023-09-21 22:04:17 +02:00
Azat Khuzhin
cc3a920073 tests: simplify test_evbuffer_add_reference_with_offset 2023-09-21 22:02:48 +02:00