fixed potential memory issue

closes https://github.com/OpenSC/OpenSC/pull/2230
This commit is contained in:
Frank Morgner 2021-02-11 11:26:59 +01:00
parent c80375eb4c
commit 999874fb1c
1 changed files with 2 additions and 1 deletions

View File

@ -583,7 +583,8 @@ static void initialize_uid(sc_reader_t *reader)
apdu.resplen = sizeof rbuf;
if (SC_SUCCESS == pcsc_transmit(reader, &apdu)
&& apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
&& apdu.sw1 == 0x90 && apdu.sw2 == 0x00
&& 0 < apdu.resplen && apdu.resplen <= SC_MAX_UID_SIZE) {
reader->uid.len = apdu.resplen;
memcpy(reader->uid.value, apdu.resp, reader->uid.len);
sc_log_hex(reader->ctx, "UID",