Skip to content

Conversation

@mdqst
Copy link

@mdqst mdqst commented Dec 1, 2024

Title:

Fix Array Index Out of Bounds Issue in Encode Function

Description:

In the original implementation of the Encode function, there was a potential issue with array indexing. The byte values in the key slice could exceed 255, leading to an out-of-bounds error when accessing the words[i%2][b] array. To prevent this, I added a check to ensure that the byte value b is always within the valid range of 0-255 by using b%256.

This change ensures that the array indices remain within the bounds of the two word lists, preventing potential runtime errors and ensuring the robustness of the encoding process.

By applying this fix, we guarantee that the Encode function will handle any byte values safely, maintaining the integrity of the word list mapping and making the code more reliable in edge cases.

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.

1 participant