Skip to content

Commit 9d77fac

Browse files
committed
catching proper exceptions
1 parent b6b3c24 commit 9d77fac

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/main/java/jadx/plugins/stringdecoder/B64Detector.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ private static B64Result attemptDecode(Base64.Decoder decoder, String str, B64De
9595
return new B64Result(truncate(decoded, options.getMaxCommentLength()), tag);
9696
} catch (CharacterCodingException ignored) {
9797
// decoded bytes are not valid UTF-8
98-
} catch (Exception ignored) {
98+
} catch (IllegalArgumentException ignored) {
99+
// decoder.decode() rejects malformed Base64
99100
}
100101
return null;
101102
}
@@ -148,7 +149,8 @@ public static B64Result decodeIfValid(String str, int maxCommentLength) {
148149
.onUnmappableCharacter(CodingErrorAction.REPORT);
149150
String decoded = utf8.decode(ByteBuffer.wrap(bytes)).toString();
150151
return new B64Result(truncate(decoded, maxCommentLength), tags[i]);
151-
} catch (Exception ignored) {
152+
} catch (IllegalArgumentException | CharacterCodingException ignored) {
153+
// decoder.decode() rejects malformed Base64; utf8.decode() rejects invalid UTF-8
152154
}
153155
}
154156
return null;
@@ -169,7 +171,8 @@ public static B64Result decodeForced(String str, int maxCommentLength) {
169171
.onUnmappableCharacter(CodingErrorAction.REPLACE);
170172
String decoded = utf8.decode(ByteBuffer.wrap(bytes)).toString();
171173
return new B64Result(truncate(decoded, maxCommentLength), ALL_DECODER_TAGS[i]);
172-
} catch (Exception ignored) {
174+
} catch (IllegalArgumentException | CharacterCodingException ignored) {
175+
// decoder.decode() rejects malformed Base64; utf8.decode() on REPLACE mode won't throw, but guard anyway
173176
}
174177
}
175178
return null;

src/main/java/jadx/plugins/stringdecoder/B64DictionaryFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private static Set<String> loadWords() {
3838
}
3939
}
4040
}
41-
} catch (Exception ignored) {
41+
} catch (java.io.IOException ignored) {
4242
}
4343
return words;
4444
}

0 commit comments

Comments
 (0)