Skip to content

Commit

Permalink
Fix wrong annotation in chunk util
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Aug 27, 2023
1 parent e523d02 commit 7b5f910
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package software.coley.recaf.util.android;

import org.checkerframework.checker.units.qual.N;
import jakarta.annotation.Nonnull;
import software.coley.recaf.util.ByteHeaderUtil;

/**
Expand All @@ -10,6 +10,16 @@
*/
public class AndroidChunkUtil {
private static int[] EMPTY_HEADER = new int[2];
private static int[] ANDROID_SCHEMA_URL = new int[]{
's', 'c', 'h', 'e', 'm', 'a', 's', '.',
'a', 'n', 'd', 'r', 'o', 'i', 'd', '.',
'c', 'o', 'm'
};
private static int[] ANDROID_SCHEMA_URL_ALT = new int[]{
's', 0, 'c', 0, 'h', 0, 'e', 0, 'm', 0, 'a', 0, 's', 0, '.', 0,
'a', 0, 'n', 0, 'd', 0, 'r', 0, 'o', 0, 'i', 0, 'd', 0, '.', 0,
'c', 0, 'o', 0, 'm', 0
};
private static int[] ANDROID_PERMISSION = new int[]{
'a', 'n', 'd', 'r', 'o', 'i', 'd', '.',
'p', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n'
Expand All @@ -25,9 +35,11 @@ public class AndroidChunkUtil {
*
* @return {@code true} if likely obscured XML chunk model.
*/
public static boolean isObscuredXml(@N byte[] data) {
public static boolean isObscuredXml(@Nonnull byte[] data) {
return ByteHeaderUtil.match(data, EMPTY_HEADER) &&
(ByteHeaderUtil.matchAtAnyOffset(data, ANDROID_PERMISSION) ||
ByteHeaderUtil.matchAtAnyOffset(data, INTENT_FILTER));
ByteHeaderUtil.matchAtAnyOffset(data, INTENT_FILTER) ||
ByteHeaderUtil.matchAtAnyOffset(data, ANDROID_SCHEMA_URL) ||
ByteHeaderUtil.matchAtAnyOffset(data, ANDROID_SCHEMA_URL_ALT));
}
}

0 comments on commit 7b5f910

Please sign in to comment.