Repository navigation
Conversation
Return CURLE_BAD_FUNCTION_ARGUMENT when NULL or zero-length buffer arguments are provided to curl_easy_ssls_import(), or when a NULL callback is passed to curl_easy_ssls_export(). Validate pointers and length in Curl_ssl_session_unpack() before dereferencing. Add unit test verifications in test1678.
|
Analysis of PR #23062 at 7d4a82e8: Test 3232 failed, but it has been 76.8% flaky lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Note that this CI job has had a number of other flaky tests recently (4, to be specific) so it may be that this failure is rather a systemic issue with this job and not with this specific PR. Test 3231 failed, but it has been 74.5% flaky lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Note that this CI job has had a number of other flaky tests recently (4, to be specific) so it may be that this failure is rather a systemic issue with this job and not with this specific PR. Generated by Testclutch |
| *ps = NULL; | ||
|
|
||
| if(!buf || !buflen) | ||
| return CURLE_BAD_FUNCTION_ARGUMENT; |
There was a problem hiding this comment.
This is an internal function that should never be called with bad parameters. I think they are better checked with DEBUGASSERT()s that make the entire thing halt in debug builds if violated, and adds nothing to release builds.
There was a problem hiding this comment.
Good point. Updated to use DEBUGASSERT for the internal Curl_ssl_session_unpack() checks while keeping argument validation in the public entry points.
Replace runtime checks in Curl_ssl_session_unpack() with DEBUGASSERTs as recommended during code review.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unpacking still relies on debug-only assertions and can dereference invalid pointers in release builds.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Hardens SSL session import/export and unpacking against invalid arguments, with regression coverage.
Changes:
- Rejects missing import data and export callbacks.
- Adds session-cache and unpacking input checks.
- Adds invalid-argument tests.
| File | Description |
|---|---|
tests/libtest/lib1678.c |
Tests invalid import/export arguments. |
lib/vtls/vtls_spack.c |
Adds unpacking checks; release-safe runtime validation remains needed. |
lib/vtls/vtls_scache.c |
Validates imported session data. |
lib/easy.c |
Validates public API arguments. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| DEBUGASSERT(ps); | ||
| DEBUGASSERT(buf); | ||
| DEBUGASSERT(buflen); |
There was a problem hiding this comment.
pff, contrary to what I just said... I say ignore the clanker.

Summary
This PR hardens the SSL session ticket import/export APIs and unpacking against NULL pointer dereferences and invalid arguments:
curl_easy_ssls_import(): returnsCURLE_BAD_FUNCTION_ARGUMENTifsdatais NULL orsdata_lenis 0. Percurl_easy_ssls_import(3),sdataandsdata_lenmust always be provided; in release builds (NDEBUG), passing NULL previously bypassedDEBUGASSERT(buf)and crashed insidespack_dec8()trying to dereference*src. Passingsdata_len == 0returnedCURLE_READ_ERRORinstead ofCURLE_BAD_FUNCTION_ARGUMENT.curl_easy_ssls_export(): returnsCURLE_BAD_FUNCTION_ARGUMENTwhenexport_fnis NULL.Curl_ssl_session_import(): validates thatsdataandsdata_lenare provided before callingCurl_ssl_session_unpack().Curl_ssl_session_unpack(): validatespsbefore initializing*ps = NULL, and validatesbufandbuflenbefore parsing.tests/libtest/lib1678.cto verify thatcurl_easy_ssls_import()andcurl_easy_ssls_export()returnCURLE_BAD_FUNCTION_ARGUMENTon invalid arguments.