cfilters: fix Curl_pollset_poll() return code mixup#21231
Closed
cfilters: fix Curl_pollset_poll() return code mixup#21231
Conversation
Curl_conn_cf_poll did not map adjust_pollset failures to poll-style errors properly, so error codes were treated as ready events. Found by Codex Security
There was a problem hiding this comment.
Pull request overview
This PR fixes an error-code mapping issue in the connection-filter polling path: Curl_conn_cf_poll() previously mixed CURLcode return values with poll-style return codes, which could cause failures from adjust_pollset to be misinterpreted as “ready events”.
Changes:
- Document poll-style return semantics for
Curl_pollset_poll()andCurl_conn_cf_poll(). - Fix
Curl_conn_cf_poll()to return a poll-styleintresult and mapadjust_pollsetfailures to-1. - Minor local variable cleanup/rename in
Curl_pollset_poll().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/select.c | Adds return-value documentation for Curl_pollset_poll() and renames local return variable. |
| lib/cfilters.c | Fixes Curl_conn_cf_poll() return-code handling to avoid treating CURLcode failures as ready events. |
Comments suppressed due to low confidence (1)
lib/select.c:668
- The new return-value comment doesn’t match the actual behavior: this function can also return -1 when
curlx_calloc()forpfdsfails (OOM), not just on poll/select errors orfd >= FD_SETSIZE(handled insideCurl_poll()). Please either update the comment to include OOM (and/or clarify that errors include allocation failures), or change the function to set an appropriate socket errno before returning -1 for allocation failures so callers get consistent diagnostics.
/*
* Return values:
* -1 = system call error or fd >= FD_SETSIZE
* 0 = timeout
* N = number of structures with non zero revent fields
*/
int Curl_pollset_poll(struct Curl_easy *data,
struct easy_pollset *ps,
timediff_t timeout_ms)
{
struct pollfd *pfds;
unsigned int i, npfds;
int rc;
(void)data;
DEBUGASSERT(data);
DEBUGASSERT(data->conn);
if(!ps->n)
return curlx_wait_ms(timeout_ms);
pfds = curlx_calloc(ps->n, sizeof(*pfds));
if(!pfds)
return -1;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dkarpov1970
pushed a commit
to dkarpov1970/curl
that referenced
this pull request
Apr 7, 2026
Curl_conn_cf_poll did not map adjust_pollset failures to poll-style errors properly, so error codes were treated as ready events. Found by Codex Security Closes curl#21231
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Curl_conn_cf_poll did not map adjust_pollset failures to poll-style errors properly, so error codes were treated as ready events.
Found by Codex Security