otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.58k stars 1.05k forks source link

Fix bank NPC overflow protection being bypassed #4693

Closed glecko closed 4 months ago

glecko commented 4 months ago

Pull Request Prelude

Changes Proposed

A bank NPC overflow protection was added back in https://github.com/otland/forgottenserver/pull/3522. However (at least with the current LuaJIT version, haven't tested others), tonumber is reserved for (and interpreted as) a standard library basic function.

This change simply renames the variable to avoid the conflict.

As a side note, when testing this (even when the check was being bypassed), I was never able to reproduce any crash, if I said "deposit [number larger than 2^32]" while having that amount of gold in my inventory, the NPC correctly allowed me to deposit & withdraw those amounts. Perhaps the check needs to be removed completly.