Skip to content

Commit

Permalink
Validate the type name in is_primitive check
Browse files Browse the repository at this point in the history
Summary: Empty strings or other types of malformed strings are not checked when we balloon the input dex code into IRCode.

Reviewed By: NTillmann

Differential Revision: D67661723

fbshipit-source-id: 8d8ec845da31cf725259ba267c6ab9079c32df7e
  • Loading branch information
Wei Zhang (Devinfra) authored and facebook-github-bot committed Dec 31, 2024
1 parent 6b1ded2 commit 1318b13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libredex/Show.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ std::string show_type(const DexType* t, bool deobfuscated) {
return std::string("");
}
auto name = t->get_name()->str();
if (!deobfuscated) {
if (!deobfuscated || name.empty()) {
return str_copy(name);
}
if (name[0] == 'L') {
Expand Down
5 changes: 4 additions & 1 deletion libredex/TypeUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ bool is_valid(std::string_view descriptor) {
}

bool is_primitive(const DexType* type) {
switch (type->get_name()->str().at(0)) {
auto const name = type->get_name()->str();
always_assert_type_log(is_valid(name), INVALID_DEX, "Invalid type name: %s",
type->get_name()->c_str());
switch (name[0]) {
case 'Z':
case 'B':
case 'S':
Expand Down

0 comments on commit 1318b13

Please sign in to comment.