fix(android): Prevent ArrayIndexOutOfBoundsException in permission check#47047
fix(android): Prevent ArrayIndexOutOfBoundsException in permission check#47047antFrancon wants to merge 1 commit into
Conversation
This commit addresses a potential ArrayIndexOutOfBoundsException in the Android module's permission checking logic. ```diff - results.length > 0 && results[j] == PackageManager.PERMISSION_GRANTED + results.length > j && results[j] == PackageManager.PERMISSION_GRANTED ``` This change ensures that we only access the results array when the index j is within bounds, preventing crashes due to invalid array access that have been occurring in the production environment.
|
Hi @antFrancon! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@cortinico merged this pull request in 6aeca53. |
|
This pull request was successfully merged by @antFrancon in 6aeca53 When will my fix make it into a release? | How to file a pick request? |
Summary:
This PR addresses a potential
ArrayIndexOutOfBoundsExceptionin the Android module's permission checking logic.It ensures that we only access the results array when the index
jis within bounds, preventing crashes due to invalid array access that have been occurring in the production environment.Here is the Crashlytics dashboard concerning this type of crash on my app last week (react-native 0.75.4 - old arch):

Changelog:
[ANDROID] [FIXED] - Prevent ArrayIndexOutOfBoundsException in permission check
Test Plan:
Verify normal permission request scenarios still work on Android:
Monitor production crash reports:
Note: As this crash was only observed in production, we'll rely on production monitoring to verify the fix's effectiveness over time.