Repository navigation
fix(config): reject DSN timeout values that overflow time.Duration - #556
Merged
Merged
Conversation
vuanhphung
marked this pull request as ready for review
November 13, 2026 16:17
ParseDSN multiplied the `timeout` seconds by time.Second without a range check, so values beyond +/-9223372036 wrapped silently: 9223372037 became -2562047h, 9223372036854775807 became -1s, and -9223372037 became +292y. Reject them with a request error naming `timeout`, like non-numeric input. In-range negative values are still accepted. Addresses #490. Co-authored-by: Isaac <[email protected]> Signed-off-by: Vu Anh Phung <[email protected]>
On 32-bit platforms strconv.Atoi rejects 9223372037 before the range check, so assert only the option name and value there. Let the kernel e2e pass its effective HTTP path so the Reyden leg targets the Reyden warehouse. Co-authored-by: Isaac <[email protected]> Signed-off-by: Vu Anh Phung <[email protected]>
vuanhphung
force-pushed
the
fix/issue-490-dsn-timeout-overflow
branch
from
November 13, 2026 23:37
f2a5a89 to
bd7a1b3
Compare
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.
The DSN
timeoutparam (seconds) was converted withtime.Duration(seconds) * time.Secondand no range check. Non-numeric and int64-overflowing values were rejected with an error namingtimeout. Anything whose nanosecond count overflows int64 wrapped silently instead:9223372037became −2562047h,9223372036854775807became −1s (the "no timeout" spelling),18446744074became 290ms, and-9223372037became +292 years.ParseDSNnow rejects values outside ±9223372036 s (math.MaxInt64/MinInt64 / time.Second) with the same request-error type and style as the existing parse error:invalid DSN: param timeout with value 9223372037 is out of range [-9223372036, 9223372036] seconds. Negative values within range, including-1, are intentionally still accepted. The DSN is the only user-supplied seconds value with this multiply pattern.WithTimeouttakes atime.Durationand can't overflow, and the other* time.Secondsites parse server headers or responses.Verification: a new table-driven
ParseDSNtest covers 0, 1, ±9223372036 (accepted), −1 (accepted), 9223372037, MaxInt64, 18446744074 and −9223372037 (rejected, namingtimeout), and the unchanged int64-overflow and non-numeric errors. Its four overflow cases fail onmain. AnOpenConnectortest asserts the error iserrors.RequestError. A live e2e on both backends opens the DSN withsql.Openand runsSELECT 1(Thrift:timeout=60and-1; kernel:0and-1), and assertstimeout=9223372037fails atsql.Open. Both legs pass, and the Thrift e2e fails onmain.make test(1317 tests),make lint(0 issues),go test -raceon the touched packages, and thedatabricks_kernel-tagged suite all pass. The one tagged failure,TestKernelCloudFetchDisabledPreservesUnsupportedServerError, fails identically onmain: it needs aKERNEL_REVnewer than the v1.4.0 bindings. Performance: the change runs once per DSN parse, not on any request or fetch path.Cross-driver state
timeout(seconds, default none). Bound ismath.MaxInt64 / time.Second; in-range negatives still acceptedsetQueryTimeout(int)can't overflow; negatives rejected withDatabricksValidationException(DatabricksStatement.java:256 @0cb8c24)queryTimeout(thrift_backend.py:1112-1133 @5a1a7ec)queryTimeoutgoes toInt64with no range or sign check (ThriftSessionBackend.ts:50-63, 204 @93a9112)DATABRICKS_KERNEL_MAX_CLIENT_QUERY_TIMEOUT_MS(9223372036854 = MaxInt64 ns / 1e6) returns InvalidArgument (vendored databricks_kernel.h:88-89)This follows the kernel's model: the bound is what the host duration type can represent, and out-of-range values are rejected, not clamped. It deviates in keeping in-range negatives, which
-1users may rely on as "no timeout".Adversarial review: converged in round 1 with no high findings; both mediums are fixed (32-bit-safe overflow assertions, kernel e2e honors the Reyden leg).
Addresses #490
This pull request and its description were written by Isaac.