Skip to content

conf: validate integer suffix overflow#8194

Draft
immanuwell wants to merge 1 commit into
nats-io:mainfrom
immanuwell:fix-config-integer-suffix-validation
Draft

conf: validate integer suffix overflow#8194
immanuwell wants to merge 1 commit into
nats-io:mainfrom
immanuwell:fix-config-integer-suffix-validation

Conversation

@immanuwell

@immanuwell immanuwell commented May 19, 2026

Copy link
Copy Markdown

Tiny config parser fix

Before, these passed config test, which is not it:

port: -1
max_payload: 1kbb
port: -1
max_payload: 9223372036854775807k

nats-server -t -c <file> reported both as valid on main. The first drops the value, the second wraps during suffix multiplication.

Now invalid suffixes error, and oversized suffixed ints error too. Existing suffixes like 22GB still work.

Tests:
go test ./conf -count=1
go test ./... -run TestNoSuchTest -count=1

@immanuwell immanuwell requested a review from a team as a code owner May 19, 2026 05:34
Signed-off-by: Immanuel Tikhonov <pchpr.00@list.ru>
@immanuwell immanuwell force-pushed the fix-config-integer-suffix-validation branch from 7fcadcf to 7d6a96a Compare May 19, 2026 05:44
Comment thread conf/parse.go
const _EMPTY_ = ""

const (
maxInt64 = int64(1<<63 - 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could use constants MaxInt64 and MinInt64 from the math package?

@neilalexander neilalexander marked this pull request as draft June 1, 2026 12:57
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.

2 participants