Summary: | KRunner currency converter can't handle large values (32-bit signed int overflow) | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kunitconversion | Reporter: | David Korth <gerbilsoft> |
Component: | general | Assignee: | John Layt <jlayt> |
Status: | CONFIRMED --- | ||
Severity: | normal | CC: | alexander.lohnau, kdelibs-bugs, zrenfire |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | KRunner showing incorrect currency conversions due to 32-bit signed int overflow. |
When typing "7000000 EUR" I get invalid results for YEN, but the others are fine. So that parsing of the input seems to be fine and it is an issue with the framework. The bug is somewhere in KUnitConversion::Value::round(2). Screenshot: https://i.imgur.com/feCDHK2.png There's an int cast: https://invent.kde.org/frameworks/kunitconversion/-/blob/master/src/value.cpp#L184 Git commit 7f672f1d47649ad17bfae61b97dd7f35e1e64727 by Alexander Lohnau. Committed on 10/03/2021 at 07:23. Pushed by alex into branch 'master'. converterrunner: Do not round values unnecassarily We pass in the precision when we format the string and the rounding causes internal issues when the value is casted to an int. Test Plan: Large queries like `100000000000000000000000000000000000000000$` no longer produce negative results. This fix can also be backported for Plasma 5.21. M +0 -1 runners/converter/converterrunner.cpp https://invent.kde.org/plasma/kdeplasma-addons/commit/7f672f1d47649ad17bfae61b97dd7f35e1e64727 |
Created attachment 131177 [details] KRunner showing incorrect currency conversions due to 32-bit signed int overflow. Attempting to convert a large currency value results in a signed integer overflow. STEPS TO REPRODUCE 1. Enter a large currency value, e.g. "700,000,000 EUR". OBSERVED RESULT Converted currency values are all "-21,474,836.48". EXPECTED RESULT Currency should be converted correctly. SOFTWARE/OS VERSIONS Linux/KDE Plasma: Gentoo Linux (available in About System) KDE Plasma Version: 5.19.2 KDE Frameworks Version: 5.73.0 Qt Version: 5.15.0