Skip to content

cf-socket: clamp keepalive seconds-to-milliseconds conversions - #23045

Closed
bagder wants to merge 2 commits into
masterfrom
bagder/keepalive-clamp
Closed

bagder wants to merge 2 commits into
masterfrom
bagder/keepalive-clamp

Conversation

@bagder

@bagder bagder commented Sep 22, 2026

Copy link
Copy Markdown
Member

On platforms that require keepalive times in milliseconds (Windows before 10.0.16299, Solaris before 11.4, DragonFlyBSD before 500702), curl converts seconds to milliseconds and starting now it prevents that multiplication from doing an integer overflow. If too large value is set, INT_MAX millisconds is used.

Reported-by: Joshua Rogers

On platforms that require keepalive times in milliseconds (Windows
before 10.0.16299, Solaris before 11.4, DragonFlyBSD before 500702),
curl converts seconds to milliseconds and starting now it prevents that
multiplication from doing an integer overflow. If too large value is
set, INT_MAX millisconds is used.

Reported-by: Joshua Rogers
@bagder
bagder marked this pull request as ready for review September 22, 2026 15:19
@bagder
bagder requested a balanced review from Copilot September 22, 2026 15:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The exact highest safely convertible value is incorrectly clamped.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Clamps keepalive second-to-millisecond conversions to prevent integer overflow on legacy platforms.

Changes:

  • Replaces unchecked multiplication with saturating conversion.
  • Applies conversion consistently across keepalive socket options.
File Description
lib/​cf-socket.c Adds overflow-safe keepalive unit conversion.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/cf-socket.c Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@bagder bagder closed this in 6c11cd4 Sep 22, 2026
@bagder
bagder deleted the bagder/keepalive-clamp branch September 22, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants