fix: OverflowException in CacheManager when reading negative IP values from SQLite#289
Open
aggus19 wants to merge 1 commit into
Open
fix: OverflowException in CacheManager when reading negative IP values from SQLite#289aggus19 wants to merge 1 commit into
aggus19 wants to merge 1 commit into
Conversation
…s from SQLite SQLite stores uint values > 2,147,483,647 as negative int64. When Dapper deserializes the address column from sa_players_ips into a uint tuple field, values like -1250625110 (which represents a valid IP as uint: 3044342186) cause a System.OverflowException. This fix changes the query tuple type from uint to long and adds an explicit cast (uint)(value & 0xFFFFFFFF) to safely convert both positive and negative stored values back to the correct uint representation. Affects: SQLite users with IP addresses in the upper half of the uint range (IPs > 128.x.x.x)
590a841 to
a7f66c0
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.
Problem
SQLite stores uint values > 2,147,483,647 as negative int64. When Dapper deserializes the
addresscolumn fromsa_players_ipsinto auinttuple field, values like -1250625110 (which represents a valid IP as uint: 3044342186) cause aSystem.OverflowException.This causes:
InitializeCacheAsync()Fix
Changes the query tuple type from
uinttolongand adds an explicit cast(uint)(value & 0xFFFFFFFF)to safely convert both positive and negative stored values back to the correct uint representation.Affected users
SQLite users with IP addresses in the upper half of the uint range (IPs > 128.x.x.x), which is the majority of public IPs.
Testing
Tested on 4 production servers running CS2-SimpleAdmin 1.7.9a with CSS 1.0.369. The OverflowException no longer occurs on startup and servers maintain stable performance over extended periods.