Hello,
I found a price overflow in the Pawn Shop service on r2083 (Classic 166 client, Interlude content).
Summary
The Pawn Shop sell price is handled as a 32-bit int, but the rest of the server handles adena as 64-bit. The default LimitItemsAmount is 256,000,000,000, and the sell price edit box accepts 12 digits (length="12" in mods/pawnshop/sell_price.htm and the Community Board version). A price above 2,147,483,647 is not rejected. It is truncated to 32 bits (value & 0xFFFFFFFF, then cast to int). The pawnshop.price column is also int(11).
Steps to reproduce
I found a price overflow in the Pawn Shop service on r2083 (Classic 166 client, Interlude content).
Summary
The Pawn Shop sell price is handled as a 32-bit int, but the rest of the server handles adena as 64-bit. The default LimitItemsAmount is 256,000,000,000, and the sell price edit box accepts 12 digits (length="12" in mods/pawnshop/sell_price.htm and the Community Board version). A price above 2,147,483,647 is not rejected. It is truncated to 32 bits (value & 0xFFFFFFFF, then cast to int). The pawnshop.price column is also int(11).
Steps to reproduce
- Open the Pawn Shop (NPC or Community Board) and choose an item to sell.
- Enter a price of 5000000000 (5 billion) with adena as the currency and confirm.
- Check the item in the buy list or in "My Items For Sale".
- The item is listed for 705,032,704 (5,000,000,000 mod 2^32), with no warning. The seller loses most of the value.
- Prices between 2,147,483,648 and 4,294,967,295 become negative.
- Either support 64-bit prices, like the private store and mail (long in the code and BIGINT in the DB),
- or reject any price above Integer.MAX_VALUE with a message, instead of silently truncating it.
- Parse the price as long and validate 0 < price <= limit before storing.
- Change pawnshop.price (and amount, if needed) to BIGINT.
- Optionally, limit the edit box length in the HTML to match the accepted maximum.