Skip to content

Fix integer overflow in whois playtime output#5177

Merged
JRoy merged 1 commit intoEssentialsX:2.xfrom
Bobcat00:playtime
Dec 6, 2022
Merged

Fix integer overflow in whois playtime output#5177
JRoy merged 1 commit intoEssentialsX:2.xfrom
Bobcat00:playtime

Conversation

@Bobcat00
Copy link
Contributor

@Bobcat00 Bobcat00 commented Dec 6, 2022

Information

This PR fixes #5176 .

Details

Proposed fix:

getStatistic() returns an int. When multiplied by 50, it can cause an integer overflow. The solution is to multiply it by a long, 50L.

Environments tested:

OS: Windows 10

Java version: 17.0.4.1

  • Most recent Paper version git-Paper-304 (MC: 1.19.2)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8

Demonstration:

Before:

[Essentials] CONSOLE issued server command: /whois Bobcat00
====== WhoIs: Bobcat00 ======
- Playtime: 16 hours 16 minutes 56 seconds
[Essentials] CONSOLE issued server command: /playtime Bobcat00
Playtime of [::CoOwner::]~Bobcat: 3 months 9 days 1 hour

After:

[Essentials] CONSOLE issued server command: /whois Bobcat00
====== WhoIs: Bobcat00 ======
- Playtime: 3 months 9 days 1 hour
[Essentials] CONSOLE issued server command: /playtime Bobcat00
Playtime of [::CoOwner::]~Bobcat: 3 months 9 days 1 hour

@JRoy JRoy merged commit 8a1e701 into EssentialsX:2.x Dec 6, 2022
@JRoy
Copy link
Member

JRoy commented Dec 6, 2022

Thanks for the catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/whois returns an incorrect value for playtime. /playtime returns the correct value.

2 participants