| Code with Finding: |
class APDUIOService {
private void setCommand(Apdu ourApdu, com.sun.javacard.apduio.Apdu theirApdu) {
byte[] buffer = ourApdu.getCommandApduBuffer();
int len = buffer.length;
/* Set lc and le... */
int lc = 0;
int le = buffer[len - 1] & 0x000000FF;
if (len == 4) {
lc = 0;
le = 0; // FIXME: maybe this should be -1?
} else if (len == 5) {
/* No cdata, byte at index 5 is le. */
lc = 0;
} else if (len > 5) {
/* Byte at index 5 is not le, so it must be lc. */
lc = buffer[ISO7816.OFFSET_LC] & 0x000000FF;
}
if (4 + lc >= len) {
/* Value of lc covers rest of apdu length, there is no le. */
le = 0; // FIXME: maybe this should be -1?
}
theirApdu.setLc(lc);
theirApdu.setLe(le);
/* Set header */
theirApdu.command = new byte[4];
System.arraycopy(buffer, 0, theirApdu.command, 0, 4);
/* Set data */
theirApdu.dataIn = new byte[lc];
System.arraycopy(buffer, ISO7816.OFFSET_CDATA, theirApdu.dataIn, 0, lc);
}
}
|