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

[Bug]: Ineffective overflow protection in CmdIncreaseLoan #10009

Closed
James103 opened this issue Sep 9, 2022 · 0 comments · Fixed by #10359
Closed

[Bug]: Ineffective overflow protection in CmdIncreaseLoan #10009

James103 opened this issue Sep 9, 2022 · 0 comments · Fixed by #10359
Labels
bug Something isn't working priority: low This issue should be fixed but has either a low impact or is en edge-case

Comments

@James103
Copy link
Contributor

James103 commented Sep 9, 2022

Version of OpenTTD

0355299

Expected result

When taking out a loan, if the total bank balance would exceed the maximum possible bank balance, the command should error.

Actual result

When taking out a loan, if the total bank balance would exceed the maximum possible bank balance, you lose some of your 'Own Funds', just enough to bring your total bank balance at or under the maximum.

Steps to reproduce

  1. Somehow acquire £ 263-1 in your 'Own Funds' or load this save: Gronnway Transport, 363576-09-15.zip
  2. Try to take out a loan.
  3. The command succeeds, but you lose some of your 'Own Funds'.

Caused by the following:

OpenTTD/src/misc_cmd.cpp

Lines 63 to 64 in 0355299

/* Overflow protection */
if (c->money + c->current_loan + loan < c->money) return CMD_ERROR;

@2TallTyler 2TallTyler added bug Something isn't working priority: low This issue should be fixed but has either a low impact or is en edge-case labels Oct 19, 2022
rubidium42 added a commit to rubidium42/OpenTTD that referenced this issue Jan 15, 2023
rubidium42 added a commit to rubidium42/OpenTTD that referenced this issue Jan 15, 2023
michicc pushed a commit to michicc/OpenTTD that referenced this issue Jan 28, 2023
michicc pushed a commit to michicc/OpenTTD that referenced this issue Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: low This issue should be fixed but has either a low impact or is en edge-case
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants