-
Notifications
You must be signed in to change notification settings - Fork 156
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
array index out of bound bug #31
Comments
Could you provide this large number? |
This piece of code is a from the reference implementation, hashids.js. In javascript As soon as you provide the test number I'll work on it. |
Maybe you want to check this block of my Hashids implementation which already handles this issue. Anyway, isn't this issue related to #30 and should already be fixed? |
@arcticicestudio I'll take a look later today. Thanks. |
Well, as long as I can tell, I found a couple of problems:
Here is a test case against master: final long[] numbers = new long[500000];
long current = Hashids.MAX_NUMBER;
for (int i = 0; i < numbers.length; i++) {
numbers[i] = current--;
}
final Hashids hid = new Hashids("abc");
hid.encode(numbers); I'll check what can be done to solve these issues, but for 1, using |
if you call the encode(number) with a random large number.
then numberHashInt += (numbers[i] % (i+100)) has a chance to return a negative number, in my case -35.
the next calculation use alphabet.toCharArray()[numberHashInt % alphabet.length()] could thow an ArrayIndexOutOfBoundsException.
The text was updated successfully, but these errors were encountered: