Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix integer overflow for amount selection #291

Merged
merged 1 commit into from
May 9, 2023

Conversation

PiRK
Copy link
Collaborator

@PiRK PiRK commented May 4, 2023

Qt translates int into a C int (32 bytes signed integer), which causes overflows when the selected amount in satoshis is larger than the int32 max.

The tradeoff of using a generic PythonObject is performance, as there will be a lot of overhead. But this is not an issue as this codepath is only triggered rarely and at low frequency, by users cliocking on coins or addresses in the GUI.

Qt translates `int` into a C int (32 bytes signed integer), which causes overflows when the selected amount in satoshis is larger than the int32 max.

The tradeoff of using a generic PythonObject is performance, as there will be a lot of overhead. But this is not an issue as this codepath is only triggered rarely and at low frequency, by users cliocking on coins or addresses in the GUI.
@PiRK PiRK merged commit 2e4aa1b into Bitcoin-ABC:master May 9, 2023
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 14, 2023
Summary:
PyQt translates python integers to signed 32 bits int when emitting a `int` in a signal.
We need to specifically emit a 64 bit integer. See https://doc.qt.io/qt-5/qtglobal.html#quint64-typedef

Also apply the same fix to the two signals that I previously fixed in a different way (with a larger performance overhead) in Bitcoin-ABC/ElectrumABC#291

Test Plan:
load a proof with a total stake of more than 21,474,836.47 XEC, check the amount is displayed correctly.
Select coins and addresses of various amounts, check the selected amount displayed in the status bar.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14781
Fabcien pushed a commit that referenced this pull request Nov 14, 2023
Summary:
PyQt translates python integers to signed 32 bits int when emitting a `int` in a signal.
We need to specifically emit a 64 bit integer. See https://doc.qt.io/qt-5/qtglobal.html#quint64-typedef

Also apply the same fix to the two signals that I previously fixed in a different way (with a larger performance overhead) in #291

Test Plan:
load a proof with a total stake of more than 21,474,836.47 XEC, check the amount is displayed correctly.
Select coins and addresses of various amounts, check the selected amount displayed in the status bar.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant