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

Integer overflow in usage request #44

Closed
lubo-dev opened this issue Aug 30, 2024 · 2 comments
Closed

Integer overflow in usage request #44

lubo-dev opened this issue Aug 30, 2024 · 2 comments

Comments

@lubo-dev
Copy link

If an account sets no character translation limit the limit is 1 000 000 000 000.
In that case requesting the usage will return a negative number for the character limit.

Minimal example:

Translator translator = new Translator(authKey)
Usage.Detail characterUsage = translator.getUsage().getCharacter();
characterUsage.getLimit() // returns -727379968

The cause of the error lies in UsageDeserializer::createDetail line 28 and 29.
There the limit and count are parsed as Integer, even though they are declared as long in Usage.Detail.
Given that the request can return a number larger than Integer::MAX_VALUE they should not only be declared as long but also parsed as such.

@lubo-dev
Copy link
Author

lubo-dev commented Aug 30, 2024

I added a pull request with a fix: #45

@lubo-dev
Copy link
Author

The fix was released with version 1.5.1

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

No branches or pull requests

1 participant