Skip to content

Commit b9bd254

Browse files
fix(android): add permission type validation in listener
- Validate that permissions array contains CAMERA permission - Prevent incorrect permission grant due to array mismatch - Add security check: permissions[0] == Manifest.permission.CAMERA - Ensure only camera permission results are processed
1 parent 9ebd4b1 commit b9bd254

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

android/src/main/java/com/pushpendersingh/reactnativescanner/ReactNativeScannerModule.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class ReactNativeScannerModule(reactContext: ReactApplicationContext) :
2222

2323
private val permissionListener = PermissionListener { requestCode, permissions, grantResults ->
2424
if (requestCode == CAMERA_PERMISSION_REQUEST_CODE) {
25-
val permissionGranted = grantResults.isNotEmpty() &&
25+
// Validate that we're handling the correct permission
26+
val permissionGranted = permissions.isNotEmpty() &&
27+
permissions[0] == Manifest.permission.CAMERA &&
28+
grantResults.isNotEmpty() &&
2629
grantResults[0] == PackageManager.PERMISSION_GRANTED
2730

2831
permissionPromise?.resolve(permissionGranted)

0 commit comments

Comments
 (0)