Skip to content

fix: detect interval overflow when reading TimeSpan - #6739

Open
Mr444-dev wants to merge 1 commit into
npgsql:mainfrom
Mr444-dev:fix/interval-timespan-overflow
Open

Mr444-dev wants to merge 1 commit into
npgsql:mainfrom
Mr444-dev:fix/interval-timespan-overflow

Conversation

@Mr444-dev

Copy link
Copy Markdown

Fixes #6726.

Compute the combined interval ticks in Int128 before converting to TimeSpan. This detects values outside the long tick range without overflowing intermediate microsecond or day calculations, so valid intervals whose components cancel remain readable.

Added coverage for positive and negative oversized intervals, oversized day values, and large components that cancel to TimeSpan.Zero.

Validation: dotnet test test/Npgsql.Tests/Npgsql.Tests.csproj --no-build --no-restore --filter 'FullyQualifiedName~Npgsql.Tests.Types.DateTimeTests' (55 passed on PostgreSQL 18, .NET SDK 10.0.401).

Copilot AI balanced review requested due to automatic review settings November 3, 2026 00:05

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 was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reading a large interval as TimeSpan returns a wrong value instead of throwing

2 participants