curl-curl/docs/libcurl
Ruocco, Calvin d3594be653
ws: tests and fixes
This started out as regression tests for the `curl_ws_recv()` and
`curl_ws_send()` implementation and ended up with a bugfix, additional
protocol validation and minor logging improvements.

- Fix reset of fragmented message decoder state when a PING/PONG is
  received in between message fragments.

- Fix undefined behavior (applying zero offset to null pointer) in
  curl_ws_send() when the given buffer is NULL.

- Detect invalid overlong PING/PONG/CLOSE frames.
- Detect invalid fragmented PING/PONG/CLOSE frames.
- Detect invalid sequences of fragmented frames.

  - a) A continuation frame (0x80...) is received without any ongoing
    fragmented message.
  - b) A new fragmented message is started (0x81/0x01/0x82/0x02...)
    before the ongoing fragmented message has terminated.

- Made logs for invalid opcodes easier to understand.
- Moved noisy logs to the `CURL_TRC_WS` log level.
- Unified the prefixes for WebSocket log messages: `[WS] ...`

- Add env var `CURL_WS_FORCE_ZERO_MASK` in debug builds.

  - If set, it forces the bit mask applied to outgoing payloads to
    0x00000000, which effectively means the payload is not masked at
    all. This drastically simplifies defining the expected `<protocol>`
    data in test cases.

- 2700: Frame types
- 2701: Invalid opcode 0x3
- 2702: Invalid opcode 0xB
- 2703: Invalid reserved bit RSV1 _(replaces 2310)_
- 2704: Invalid reserved bit RSV2
- 2705: Invalid reserved bit RSV3
- 2706: Invalid masked server message
- 2707: Peculiar frame sizes _(part. replaces 2311)_
- 2708: Automatic PONG
- 2709: No automatic PONG _(replaces 2312)_
- 2710: Unsolicited PONG
- 2711: Empty PING/PONG/CLOSE
- 2712: Max sized PING/PONG/CLOSE
- 2713: Invalid oversized PING _(replaces 2307)_
- 2714: Invalid oversized PONG
- 2715: Invalid oversized CLOSE
- 2716: Invalid fragmented PING
- 2717: Invalid fragmented PONG
- 2718: Invalid fragmented CLOSE
- 2719: Fragmented messages _(part. replaces 2311)_
- 2720: Fragmented messages with empty fragments
- 2721: Fragmented messages with interleaved pong
- 2722: Invalid fragmented message without initial frame
- 2723: Invalid fragmented message without final frame

- 2305: curl_ws_recv() loop reading three larger frames
  - This test involuntarily sent an invalid sequence of opcodes (0x01...,0x01...,0x81...) , but neither libcurl nor the test caught this! The correct sequence was tested in 2311 (0x01...,0x00...,0x80...). See below for 2311.
  - Validation of the opcode sequence was added to libcurl and is now tested in 2723.
  - Superseded by 2719 (fragmented message) and 2707 (large frames).
- 2307: overlong PING payload
  - The tested PING payload length check was actually missing, but the test didn't catch this since it involuntarily sent an invalid opcode (0x19... instead of 0x89...) so that the expected error occurred, but for the wrong reason.
  - Superseded by 2713.
- 2310: unknown reserved bit set in frame header
  - Superseded by 2703 and extended by 2704 and 2705.
- 2311: curl_ws_recv() read fragmented message
  - Superseded by 2719 (fragmented message) and 2707 (large frames).
- 2312: WebSockets no auto ping
  - Superseded by 2709.

- No tests for `CURLOPT_WRITEFUNCTION`.
- No tests for sending of invalid frames/fragments.

Closes #17136
2025-06-02 11:15:38 +02:00
..
opts spelling: call it null-terminate consistently 2025-05-30 17:29:45 +02:00
.gitignore gitignore: the generated libcurl-symbols.md 2024-01-25 16:34:06 +01:00
ABI.md docs: use present tense 2024-02-27 09:47:21 +01:00
CMakeLists.txt cmake: add custom command scripts as dependencies where missing 2025-03-26 15:31:53 +01:00
curl_easy_cleanup.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_easy_duphandle.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_easy_escape.md curl_easy_escape.md: move historic details to HISTORY 2024-07-23 11:24:19 +02:00
curl_easy_getinfo.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_easy_header.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_easy_init.md docs: use lowercase curl and libcurl 2025-01-02 17:15:54 +01:00
curl_easy_nextheader.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_easy_option_by_id.md docs: minor edits to please the new spellchecker regime 2025-02-27 13:15:21 +01:00
curl_easy_option_by_name.md docs: minor edits to please the new spellchecker regime 2025-02-27 13:15:21 +01:00
curl_easy_option_next.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_easy_pause.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_easy_perform.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_easy_recv.md docs/libcurl: fix type and prototype problems in examples 2025-04-29 22:44:05 +02:00
curl_easy_reset.md docs: use lowercase curl and libcurl 2025-01-02 17:15:54 +01:00
curl_easy_send.md docs/libcurl: fix type and prototype problems in examples 2025-04-29 22:44:05 +02:00
curl_easy_setopt.md TLS: add CURLOPT_SSL_SIGNATURE_ALGORITHMS and --sigalgs 2025-04-30 17:47:22 +02:00
curl_easy_ssls_export.md spelling: call it null-terminate consistently 2025-05-30 17:29:45 +02:00
curl_easy_ssls_import.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_easy_strerror.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_easy_unescape.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
curl_easy_upkeep.md mqtt: send ping at upkeep interval 2025-04-16 09:36:19 +02:00
curl_escape.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
curl_formadd.md spelling: call it null-terminate consistently 2025-05-30 17:29:45 +02:00
curl_formfree.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
curl_formget.md docs: minor edits to please the new spellchecker regime 2025-02-27 13:15:21 +01:00
curl_free.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
curl_getdate.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_getenv.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
curl_global_cleanup.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_global_init_mem.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_global_init.md tidy-up: OS names 2024-08-04 19:17:45 +02:00
curl_global_sslset.md curl_global_sslset.md: Add SSL backend names 2025-02-09 14:56:06 -05:00
curl_global_trace.md VERSIONS: list all past releases 2025-04-03 08:26:33 +02:00
curl_mime_addpart.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_mime_data_cb.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_mime_data.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_mime_encoder.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_mime_filedata.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_mime_filename.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_mime_free.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_mime_headers.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_mime_init.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_mime_name.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_mime_subparts.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_mime_type.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_mprintf.md spacecheck.pl: drop more exceptions 2025-05-13 16:01:07 +02:00
curl_multi_add_handle.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_multi_assign.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_multi_cleanup.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_multi_fdset.md docs: add FD_ZERO to curl_multi_fdset example 2025-02-14 08:21:42 +01:00
curl_multi_get_handles.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_multi_info_read.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_multi_init.md docs/libcurl: expand multi documentation 2024-10-01 15:17:17 +02:00
curl_multi_perform.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_multi_poll.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_multi_remove_handle.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_multi_setopt.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_multi_socket_action.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_multi_socket_all.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_multi_socket.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_multi_strerror.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_multi_timeout.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_multi_wait.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_multi_waitfds.md curl_multi_waitfds.md: tidy up the example 2025-01-19 11:45:25 +01:00
curl_multi_wakeup.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_pushheader_byname.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_pushheader_bynum.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_share_cleanup.md docs/libcurl: add to cleanup docs that their inputs go invalid 2024-07-23 11:18:46 +02:00
curl_share_init.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_share_setopt.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_share_strerror.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_slist_append.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_slist_free_all.md docs/libcurl: make examples build with picky compiler options 2025-04-11 15:23:51 +02:00
curl_strequal.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_strnequal.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_unescape.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_url_cleanup.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
curl_url_dup.md docs/libcurl: return value overhall 2025-01-02 16:58:05 +01:00
curl_url_get.md spelling: call it null-terminate consistently 2025-05-30 17:29:45 +02:00
curl_url_set.md urlapi: redirecting to "" is considered fine 2025-04-25 22:38:04 +02:00
curl_url_strerror.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_url.md curldown: fixups 2024-07-19 17:03:25 +02:00
curl_version_info.md curl_version_info.md: clarify ssl_version for MultiSSL 2025-05-11 12:23:36 -04:00
curl_version.md curl_version_info.md: clarify ssl_version for MultiSSL 2025-05-11 12:23:36 -04:00
curl_ws_meta.md docs/libcurl: fix type and prototype problems in examples 2025-04-29 22:44:05 +02:00
curl_ws_recv.md curl_ws_recv.md: expand a little on the fragments the API delivers 2025-03-14 13:36:02 +01:00
curl_ws_send.md ws: fix and extend CURLWS_CONT handling 2025-03-14 11:46:36 +01:00
libcurl-easy.md curldown: make 'added-in:' a mandatory header field 2024-07-18 18:04:09 +02:00
libcurl-env-dbg.md ws: tests and fixes 2025-06-02 11:15:38 +02:00
libcurl-env.md spelling: 'a' vs 'an' 2025-05-30 11:38:35 +02:00
libcurl-errors.md spelling: 'a' vs 'an' 2025-05-30 11:38:35 +02:00
libcurl-multi.md curldown: make 'added-in:' a mandatory header field 2024-07-18 18:04:09 +02:00
libcurl-security.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
libcurl-share.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
libcurl-thread.md tidy-up: URL updates 2024-07-30 21:27:12 +02:00
libcurl-tutorial.md libcurl-tutorial.md: fix read callback explanation 2025-04-23 23:23:59 +02:00
libcurl-url.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
libcurl-ws.md websocket: add option to disable auto-pong reply 2025-04-19 00:01:28 +02:00
libcurl.m4 misc: Fix typos in docs and lib 2024-03-01 09:59:48 +01:00
libcurl.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
Makefile.am docs: dist curl*.1 and install without perl 2024-02-20 10:35:13 +01:00
Makefile.inc tidy-up: .gitignore lines mostly 2025-01-27 20:59:46 +01:00
mksymbolsmanpage.pl curldown: make 'added-in:' a mandatory header field 2024-07-18 18:04:09 +02:00
symbols-in-versions TLS: add CURLOPT_SSL_SIGNATURE_ALGORITHMS and --sigalgs 2025-04-30 17:47:22 +02:00
symbols.pl docs: remove use of the word 'very' 2023-09-07 22:52:07 +02:00