Fix myTeamSpeak sign-in for accounts with add-on items

The server returns every item class the account holds, not only the
requested ones, and add-on items come unencrypted. Decrypting them failed
the integrity check and aborted the whole import. Only decrypt the
classes that were asked for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 12:14:43 +00:00
co-authored by Claude Opus 5.5
parent ad9dfa5be0
commit cbe92e84ff
2 changed files with 36 additions and 14 deletions
@@ -184,25 +184,41 @@ public final class MyTeamSpeak {
return items;
}
/** The encrypted items of one {@code Sync_ItemClasses_Data}; tombstones carry none. */
/**
* The encrypted items of one {@code Sync_ItemClasses_Data}; tombstones carry none.
* The server answers with every class the account holds, whatever was asked for,
* and not all of them are encrypted (add-on flags come in the clear), so only the
* wanted classes are kept.
*/
private static void collectFrames(ProtobufReader itemClass, List<byte[]> frames) throws IOException {
int classId = 0;
List<byte[]> blobs = new ArrayList<>();
while (itemClass.next()) {
if (itemClass.fieldNumber() != 3) {
itemClass.skip();
continue;
}
ProtobufReader detail = itemClass.readMessage();
byte[] blob = null;
boolean deleted = false;
while (detail.next()) {
switch (detail.fieldNumber()) {
case 3 -> blob = detail.readBytes();
case 4 -> deleted = detail.readBool();
default -> detail.skip();
switch (itemClass.fieldNumber()) {
case 1 -> classId = (int) itemClass.readVarint();
case 3 -> {
byte[] blob = itemBlob(itemClass.readMessage());
if (blob != null) blobs.add(blob);
}
default -> itemClass.skip();
}
if (!deleted && blob != null && blob.length > 0) frames.add(blob);
}
for (int wanted : ITEM_CLASSES) {
if (wanted == classId) frames.addAll(blobs);
}
}
private static byte[] itemBlob(ProtobufReader detail) throws IOException {
byte[] blob = null;
boolean deleted = false;
while (detail.next()) {
switch (detail.fieldNumber()) {
case 3 -> blob = detail.readBytes();
case 4 -> deleted = detail.readBool();
default -> detail.skip();
}
}
return !deleted && blob != null && blob.length > 0 ? blob : null;
}
/** Ends the session rather than leave it for the server to expire; nothing to do if that fails. */