fixed potentially dereferencing null pointer

This commit is contained in:
Frank Morgner
2015-01-25 03:53:52 +01:00
parent f03760e27e
commit feebfe7a74
4 changed files with 14 additions and 7 deletions

View File

@@ -588,7 +588,7 @@ static int boxing_pin_cmd_to_buf(sc_context_t *ctx,
err: err:
free(pinapdu); free(pinapdu);
if (r < 0 && *pc_to_rdr_secure) { if (r < 0 && pc_to_rdr_secure && *pc_to_rdr_secure) {
free(*pc_to_rdr_secure); free(*pc_to_rdr_secure);
*pc_to_rdr_secure = NULL; *pc_to_rdr_secure = NULL;
} }
@@ -925,8 +925,9 @@ void sc_detect_boxing_cmds(sc_reader_t *reader)
|| apdu.sw2 != 0x00 || apdu.sw2 != 0x00
|| boxing_buf_to_pace_capabilities(reader->ctx, || boxing_buf_to_pace_capabilities(reader->ctx,
apdu.resp, apdu.resplen, &capabilities) != SC_SUCCESS) { apdu.resp, apdu.resplen, &capabilities) != SC_SUCCESS) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL, if (reader)
"%s does not support boxing commands", reader->name); sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
"%s does not support boxing commands", reader->name);
} else { } else {
if (capabilities & SC_READER_CAP_PIN_PAD if (capabilities & SC_READER_CAP_PIN_PAD
&& !(reader->capabilities & SC_READER_CAP_PIN_PAD)) { && !(reader->capabilities & SC_READER_CAP_PIN_PAD)) {

View File

@@ -219,7 +219,7 @@ static void npa_cache_or_free(sc_card_t *card,
{ {
struct npa_drv_data *drv_data; struct npa_drv_data *drv_data;
if (card->drv_data) { if (card && card->drv_data) {
drv_data = card->drv_data; drv_data = card->drv_data;
if (ef_cardaccess && ef_cardaccess_length if (ef_cardaccess && ef_cardaccess_length

View File

@@ -1739,7 +1739,10 @@ err:
BUF_MEM_clear_free(nonce); BUF_MEM_clear_free(nonce);
BUF_MEM_clear_free(signature); BUF_MEM_clear_free(signature);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); if (card)
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
else
return r;
} }
static int npa_mse_set_at_ca(sc_card_t *card, int protocol) static int npa_mse_set_at_ca(sc_card_t *card, int protocol)
@@ -1931,7 +1934,10 @@ err:
BUF_MEM_clear_free(token); BUF_MEM_clear_free(token);
BUF_MEM_clear_free(eph_pub_key); BUF_MEM_clear_free(eph_pub_key);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); if (card)
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
else
return r;
} }
static const char *MRZ_name = "MRZ"; static const char *MRZ_name = "MRZ";

View File

@@ -295,7 +295,7 @@ IFDHTransmitToICC (DWORD Lun, SCARD_IO_HEADER SendPci, PUCHAR TxBuffer,
r = IFD_SUCCESS; r = IFD_SUCCESS;
err: err:
if (r != IFD_SUCCESS) if (r != IFD_SUCCESS && RxLength)
*RxLength = 0; *RxLength = 0;
free(rapdu); free(rapdu);