Skip to content

Commit 2036f12

Browse files
committed
Fix handling of very long display names
1 parent 4a99be9 commit 2036f12

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/us/q3q/fido2/FIDO2Applet.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,7 +3286,7 @@ private short consumeMapAndGetID(APDU apdu, byte[] buffer, short readIdx, short
32863286
if (checkAllFieldsText && !isId && valDef == 0x58) {
32873287
sendErrorByte(apdu, FIDOConstants.CTAP2_ERR_CBOR_UNEXPECTED_TYPE);
32883288
}
3289-
valLen = buffer[readIdx++];
3289+
valLen = ub(buffer[readIdx++]);
32903290
if (isId) {
32913291
idPos++;
32923292
}
@@ -3304,7 +3304,7 @@ private short consumeMapAndGetID(APDU apdu, byte[] buffer, short readIdx, short
33043304
if (isId && byteString) {
33053305
sendErrorByte(apdu, FIDOConstants.CTAP2_ERR_CBOR_UNEXPECTED_TYPE);
33063306
}
3307-
valLen = (byte) (valDef - 0x60);
3307+
valLen = (short)(valDef - 0x60);
33083308
} else if (valDef >= 0x40 && valDef < 0x58) {
33093309
if (isId && !byteString) {
33103310
sendErrorByte(apdu, FIDOConstants.CTAP2_ERR_CBOR_UNEXPECTED_TYPE);
@@ -3317,12 +3317,15 @@ private short consumeMapAndGetID(APDU apdu, byte[] buffer, short readIdx, short
33173317
if (checkAllFieldsText && !isId) {
33183318
sendErrorByte(apdu, FIDOConstants.CTAP2_ERR_CBOR_UNEXPECTED_TYPE);
33193319
}
3320-
valLen = (byte) (valDef - 0x40);
3320+
valLen = (short) (valDef - 0x40);
33213321
} else {
33223322
sendErrorByte(apdu, FIDOConstants.CTAP2_ERR_CBOR_UNEXPECTED_TYPE);
33233323
}
33243324

33253325
if (isId) {
3326+
if (valLen > 255) {
3327+
sendErrorByte(apdu, FIDOConstants.CTAP2_ERR_REQUEST_TOO_LARGE);
3328+
}
33263329
foundId = true;
33273330
transientStorage.setStoredVars(idPos, (byte) valLen);
33283331
}

0 commit comments

Comments
 (0)