Repository navigation
Conversation
7195fa5 to
5d69c4c
Compare
|
While looking into the test 621 hang, I found busy loops in SCP error cleanup. Both I reproduced this with synthetic I/O callbacks, though I haven't confirmed whether it explains the original CI hang. I have a local patch using the existing Would you like me to open a separate PR for the SCP fix? |
There was a problem hiding this comment.
🟡 Changes recommended
The new CI job’s overall timeout is currently set such that it can terminate the test step prematurely after earlier build/install work consumes part of the budget.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR extends Windows WinCNG validation by adding a CI job that builds libssh2 with MSVC and runs curl’s runtest SCP/SFTP tests against it, and adjusts WinCNG big-number handling to ensure normalized (no leading-zero) representations in key exchange outputs.
Changes:
- Add
wcng_bn_normalize()and apply it to WinCNG BN outputs (ECDH secret, DH public key, DH shared secret) to produce normalized big-number byte strings. - Add a new GitHub Actions job (
build_msvc_curl) that builds libssh2 (WinCNG) and curl from source on Windows, then runs curl’s SCP/SFTP runtests.
File summaries
| File | Description |
|---|---|
src/wincng.c |
Normalizes WinCNG big-number buffers after key/secret generation to avoid leading-zero artifacts. |
.github/workflows/ci.yml |
Adds a Windows MSVC+MSYS2-based CI job to build curl against libssh2 and run SCP/SFTP runtests. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Certainly! |
SCP receive and send error cleanup currently keeps retrying `libssh2_channel_free()` when it returns `LIBSSH2_ERROR_EAGAIN`, including in non-blocking mode. Use the existing `ssh2_NB_state_error_closing` state to return control to the caller and resume cleanup on the next call. Preserve the original error code, message, and ownership flags until cleanup finishes. Release a saved heap-owned message if the session is freed before cleanup completes. Add a bounded, network-free standalone regression covering receive/send cleanup across calls, restoration of the original error, and saved-message lifetime through completion or session teardown. It uses the common SCP/channel code and does not require a particular crypto backend. Follow-up to libssh2#2590 (comment). I have not established whether this explains the original test 621 CI hang. The curl runtime suite and upstream CI matrix have not been run for this branch. 2591
58d285f to
20cd62c
Compare
SCP receive and send error cleanup currently keeps retrying `libssh2_channel_free()` when it returns `LIBSSH2_ERROR_EAGAIN`, including in non-blocking mode. Use the existing `ssh2_NB_state_error_closing` state to return control to the caller and resume cleanup on the next call. Preserve the original error code, message, and ownership flags until cleanup finishes. Release a saved heap-owned message if the session is freed before cleanup completes. Add a bounded, network-free standalone regression covering receive/send cleanup across calls, restoration of the original error, and saved-message lifetime through completion or session teardown. It uses the common SCP/channel code and does not require a particular crypto backend. Follow-up to libssh2#2590 (comment). I have not established whether this explains the original test 621 CI hang. The curl runtime suite and upstream CI matrix have not been run for this branch. 2591
7e4e23b to
8897542
Compare
- normalize fixed-width WinCNG bignums before SSH `mpint` serialization - apply the normalization to DH public values and DH/ECDH shared secrets - zero the removed tail bytes and add common bignum conversion tests WinCNG returns DH public values and raw DH/ECDH shared secrets in fixed-width buffers. The WinCNG bignum retained that buffer width as its numeric length. When a value started with `0x00`, libssh2 included the redundant byte in the exchange hash even though RFC 4251 requires a canonical `mpint` representation. The peer hashes the normalized integer, so the exchange hashes differ and a valid server host-key signature is rejected. This appeared intermittently as `LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE` because it depends on the generated value. The helper introduced here moves significant bytes to the start of the existing allocation, explicitly clears the removed tail, and updates only the logical length. It does not add an allocation or a new failure path. Reported-by: Dan Fandrich Fixes #804 Ref: #2590 (tests) Closes #2583
``` curl: (2) Failure establishing ssh session: -8, Unable to exchange encryption keys ``` https://github.com/libssh2/libssh2/actions/runs/33995660051/job/101385680240#step:12:2364
This reverts commit 18d53ed.
…iting for potential flaky hangs
This reverts commit 1715d4ed84861f6b762cb18fdb0498d84a6d2468.
8897542 to
70176eb
Compare
…man-group16-sha512` To use a superior fallback KEX. Refs: https://datatracker.ietf.org/doc/html/rfc9142 https://github.blog/changelog/2026-09-22-security-improvements-for-ssh/ Follow-up to bb8e095 #2590 Closes #2648
From `CURL_VERSION`. To avoid confusion with the non-debug `CURL_VERSION` macro, and to avoid possible, difficult-to-track-down collision when `CURL_VERSION` is legitimately used for something else. Refs: libssh2/libssh2@51333f9 libssh2/libssh2#2590 libssh2/libssh2@bb8e095
From `CURL_VERSION`. To avoid confusion with the non-debug `CURL_VERSION` macro, and to avoid possible, difficult-to-track-down fallouts when `CURL_VERSION` is legitimately used for something else. Refs: libssh2/libssh2@51333f9 libssh2/libssh2#2590 libssh2/libssh2@bb8e095 Closes #23252
In an attempt to improve stability / reduce flakiness of these tests. Especially the ECDSA-enable ones were prone to mass fail. ``` 22:49:30.110000 * Failure establishing ssh session: -43, Failed getting banner ``` Ref: https://github.com/libssh2/libssh2/actions/runs/38480041149/job/115580107883#step:11:1034 This is a different failure than the long-chased flaky -8 kex failures, which was fixed earlier and did not reoccur since then. Follow-up to 5bfa574 #2603 Follow-up to f216bbe #2583 Follow-up to bb8e095 #2590 Closes #2666
The WinCNG backend has been missing runtime tests for a while. To
restore some level of testing, this PR make use of curl's regression
test suite (
runtests) to run SCP/SFTP-specific tests with themaster/PR libssh2 revision at hand. Some tests need to be disabled when
using the built-in Windows OpenSSH server.
The current CI jobs reproduce the long-running WinCNG flaky failure
reported in #804 reliability.
Note, if these CI jobs make libssh2 CI a pain to use, they will be
removed. This has a reasonably fair chance to happen, based on the
experience with curl CI with Windows.
Also:
This may be lowered in a future commit to avoid flakiness and reduce
CI load and job times.
Caveats:
and error 2304 for undiscovered reasons.
Discussion: Windows CI/GHA, jobs failing curl/curl#14854
successful run a failure.
Refs:
curl/curl@a477789
GHA/windows: switch from MSBuild to Ninja for MSVC jobs running tests curl/curl#18301
always enabled.
Ref: #2049
Ref: #2583
TODO: