Skip to content

Commit

Permalink
Fix buffer overrun fix
Browse files Browse the repository at this point in the history
The initial patch from Jakub was at the correct place in code.
  • Loading branch information
LudovicRousseau committed May 24, 2024
1 parent b12284b commit bbb5327
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,6 @@ RESPONSECODE SecurePINVerify(unsigned int reader_index,
#define T1_S_TYPE(pcb) ((pcb) & 0x0F)
#define T1_S_WTX 0x03

/* this should not happen. It will make coverity happy */
if (*RxLength < 4)
{
ret = IFD_COMMUNICATION_ERROR;
goto end;
}

/* WTX S-block */
if ((T1_S_BLOCK | T1_S_WTX) == RxBuffer[PCB])
{
Expand Down Expand Up @@ -593,6 +586,13 @@ RESPONSECODE SecurePINVerify(unsigned int reader_index,
ccid_descriptor->readTimeout = oldReadTimeout;
}

/* this should not happen. It will make coverity happy */
if (*RxLength < 4)
{
ret = IFD_COMMUNICATION_ERROR;
goto end;
}

/* get only the T=1 data */
memmove(RxBuffer, RxBuffer+3, *RxLength -4);
*RxLength -= 4; /* remove NAD, PCB, LEN and CRC */
Expand Down

0 comments on commit bbb5327

Please sign in to comment.