Skip to content

Commit

Permalink
Don't panic if encountering adb entries with unknown "version" prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thenickdude committed Mar 25, 2024
1 parent cf62087 commit 69e5823
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions c42-adbtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,16 @@ void commandListEntries(ADB *adb) {
adb->readAllEntries(values);

for (auto pair : values) {
if (pair.first.empty() || pair.first[0] != ADB_KEY_PREFIX[0]) {
// There seems to be "version 2" keys prefixed with \x02 instead, but these values don't serve an obvious purpose
// Skip them since we'll only offer to write \x01 keys anyway
continue;
}

bool printable = true;

for (int i = 0; i < pair.second.length(); i++) {
if (!isprint(pair.second[i]) && !isspace(pair.second[i])) {
if (pair.second[i] < ' ' || pair.second[i] > '~') {
printable = false;
break;
}
Expand All @@ -126,7 +132,9 @@ void commandListKeys(ADB *adb) {
adb->readAllKeys(values);

for (auto key : values) {
std::cout << trimADBKeyPrefix(key) << std::endl;
if (!key.empty() && key[0] == ADB_KEY_PREFIX[0]) {
std::cout << trimADBKeyPrefix(key) << std::endl;
}
}
}

Expand Down

0 comments on commit 69e5823

Please sign in to comment.