Fix with data and extended length.

This commit is contained in:
Pol Henarejos
2022-05-30 00:51:36 +02:00
parent acde4c54d5
commit 58e9e67ee5

View File

@@ -234,13 +234,14 @@ static int usb_event_handle() {
if (apdu.ne == 0) if (apdu.ne == 0)
apdu.ne = 256; apdu.ne = 256;
} }
else if (ccid_header->dwLength == 7) { else if (apdu.header[4] == 0x0 && ccid_header->dwLength >= 7) {
apdu.nc = 0; if (ccid_header->dwLength == 7) {
apdu.ne = (apdu.header[5] << 8) | apdu.header[6]; apdu.ne = (apdu.header[5] << 8) | apdu.header[6];
if (apdu.ne == 0) if (apdu.ne == 0)
apdu.ne = 65536; apdu.ne = 65536;
} }
else if (apdu.header[4] == 0x0) { else {
apdu.ne = 0;
apdu.nc = (apdu.header[5] << 8) | apdu.header[6]; apdu.nc = (apdu.header[5] << 8) | apdu.header[6];
apdu.data = apdu.header+7; apdu.data = apdu.header+7;
if (apdu.nc+7+2 == ccid_header->dwLength) { if (apdu.nc+7+2 == ccid_header->dwLength) {
@@ -249,6 +250,7 @@ static int usb_event_handle() {
apdu.ne = 65536; apdu.ne = 65536;
} }
} }
}
else { else {
apdu.nc = apdu.header[4]; apdu.nc = apdu.header[4];
apdu.data = apdu.header+5; apdu.data = apdu.header+5;