Skip to content

[#709] Reject integers outside int range in as_int - #721

Open
Keshavkumar04 wants to merge 1 commit into
pgexporter:mainfrom
Keshavkumar04:range-check-as-int
Open

Keshavkumar04 wants to merge 1 commit into
pgexporter:mainfrom
Keshavkumar04:range-check-as-int

Conversation

@Keshavkumar04

Copy link
Copy Markdown
Contributor

Same narrowing as pgmoneta/pgmoneta#1728. as_int checks ERANGE, which only covers long range, then casts to int unchecked, so -2147483649 arrives as 2147483647.

The new test fails on unfixed code and passes with the fix.

Closes #709

@Pranav-error

Copy link
Copy Markdown
Collaborator

#692 is merged now. It fixes the Debug crash in test_connection_bind_unix_socket_permissions (#691), which is what fails both build-linux Debug jobs here. Please rebase on main.

The ERANGE check covers long, so a value between INT_MAX and LONG_MAX was
accepted and then narrowed: 2147483648 became -2147483648 and -2147483649
became INT_MAX.

Signed-off-by: Keshav Kumar <[email protected]>
@Keshavkumar04

Copy link
Copy Markdown
Contributor Author

#692 is merged now. It fixes the Debug crash in test_connection_bind_unix_socket_permissions (#691), which is what fails both build-linux Debug jobs here. Please rebase on main.

Rebased on main, thanks for tracking that down.

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.

as_int accepts values outside int range and truncates them

2 participants