kaoh / globalplatform

C library + command-line for Open- / GlobalPlatform smart cards
https://kaoh.github.io/globalplatform/
Other
72 stars 30 forks source link

fatal error in load_from_buffer #15

Closed kaoh closed 4 years ago

kaoh commented 13 years ago

wrong usage of switch statement prevents applets with size <256 byte from uploading on card.

// Enough space left to start load file data block

if ((MAX_APDU_DATA_SIZE_FOR_SECURE_MESSAGING-j) > fileSizeSize+1+1) { // At least one byte of the load file data block must be sent.
    sendBuffer[5+j++] = 0xC4;
    switch(fileSizeSize) {
        case 1: {
            sendBuffer[5+j++] = (BYTE)loadFileBufSize;
                            break; // bugfix
                }
        case 2: {
            sendBuffer[5+j++] = 0x81;
            sendBuffer[5+j++] = (BYTE)loadFileBufSize;
                            break; // bugfix
                }
        case 3: {
            sendBuffer[5+j++] = 0x82;
            sendBuffer[5+j++] = (BYTE)(loadFileBufSize >> 8);
            sendBuffer[5+j++] = (BYTE)(loadFileBufSize - (sendBuffer[5+j-1] << 8));
                }
    }

Reported by: *anonymous

kaoh commented 13 years ago

Thanks a lot. This is now part of the trunk.

Original comment by: kaoh