- removed unnecessary checks of NULL pointer before using free()
- fixed memory leak for buergerclient workaround git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@270 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -502,8 +502,7 @@ perform_PC_to_RDR_XfrBlock(const u8 *in, size_t inlen, __u8** out, size_t *outle
|
|||||||
sc_result = get_RDR_to_PC_DataBlock(request->bSlot, request->bSeq, sc_result,
|
sc_result = get_RDR_to_PC_DataBlock(request->bSlot, request->bSeq, sc_result,
|
||||||
out, outlen, abDataOut, abDataOutLen);
|
out, outlen, abDataOut, abDataOutLen);
|
||||||
|
|
||||||
if (abDataOut)
|
free(abDataOut);
|
||||||
free(abDataOut);
|
|
||||||
|
|
||||||
return sc_result;
|
return sc_result;
|
||||||
}
|
}
|
||||||
@@ -783,15 +782,15 @@ perform_PC_to_RDR_Secure_EstablishPACEChannel(sc_card_t *card,
|
|||||||
__le16 word;
|
__le16 word;
|
||||||
__u8 *p;
|
__u8 *p;
|
||||||
|
|
||||||
|
memset(&pace_input, 0, sizeof(pace_input));
|
||||||
|
memset(&pace_output, 0, sizeof(pace_output));
|
||||||
|
|
||||||
|
|
||||||
if (!abDataOut || !abDataOutLen) {
|
if (!abDataOut || !abDataOutLen) {
|
||||||
sc_result = SC_ERROR_INVALID_ARGUMENTS;
|
sc_result = SC_ERROR_INVALID_ARGUMENTS;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&pace_input, 0, sizeof(pace_input));
|
|
||||||
memset(&pace_output, 0, sizeof(pace_output));
|
|
||||||
|
|
||||||
|
|
||||||
if (abDatalen < parsed+1) {
|
if (abDatalen < parsed+1) {
|
||||||
sc_error(ctx, "Buffer too small, could not get PinID");
|
sc_error(ctx, "Buffer too small, could not get PinID");
|
||||||
sc_result = SC_ERROR_INVALID_ARGUMENTS;
|
sc_result = SC_ERROR_INVALID_ARGUMENTS;
|
||||||
@@ -959,14 +958,16 @@ perform_PC_to_RDR_Secure_EstablishPACEChannel(sc_card_t *card,
|
|||||||
sc_result = SC_SUCCESS;
|
sc_result = SC_SUCCESS;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (pace_output.recent_car)
|
#ifdef BUERGERCLIENT_WORKAROUND
|
||||||
free(pace_output.recent_car);
|
ef_cardaccess = pace_output.ef_cardaccess;
|
||||||
if (pace_output.previous_car)
|
ef_cardaccess_length = pace_output.ef_cardaccess_length;
|
||||||
free(pace_output.previous_car);
|
#else
|
||||||
if (pace_output.id_icc)
|
free(pace_output.ef_cardaccess;
|
||||||
free(pace_output.id_icc);
|
#endif
|
||||||
if (pace_output.id_pcd)
|
free(pace_output.recent_car);
|
||||||
free(pace_output.id_pcd);
|
free(pace_output.previous_car);
|
||||||
|
free(pace_output.id_icc);
|
||||||
|
free(pace_output.id_pcd);
|
||||||
|
|
||||||
return sc_result;
|
return sc_result;
|
||||||
}
|
}
|
||||||
@@ -1029,6 +1030,10 @@ perform_PC_to_RDR_Secure(const __u8 *in, size_t inlen, __u8** out, size_t *outle
|
|||||||
size_t abDataOutLen = 0;
|
size_t abDataOutLen = 0;
|
||||||
RDR_to_PC_DataBlock_t *result;
|
RDR_to_PC_DataBlock_t *result;
|
||||||
|
|
||||||
|
memset(&curr_pin, 0, sizeof(curr_pin));
|
||||||
|
memset(&new_pin, 0, sizeof(new_pin));
|
||||||
|
|
||||||
|
|
||||||
if (!in || !out || !outlen)
|
if (!in || !out || !outlen)
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
@@ -1038,9 +1043,6 @@ perform_PC_to_RDR_Secure(const __u8 *in, size_t inlen, __u8** out, size_t *outle
|
|||||||
if (request->bMessageType != 0x69)
|
if (request->bMessageType != 0x69)
|
||||||
sc_debug(ctx, "warning: malformed PC_to_RDR_Secure");
|
sc_debug(ctx, "warning: malformed PC_to_RDR_Secure");
|
||||||
|
|
||||||
memset(&curr_pin, 0, sizeof(curr_pin));
|
|
||||||
memset(&new_pin, 0, sizeof(new_pin));
|
|
||||||
|
|
||||||
if (request->bSlot > sizeof *card_in_slot) {
|
if (request->bSlot > sizeof *card_in_slot) {
|
||||||
sc_error(ctx, "Received request to invalid slot (bSlot=0x%02x)", request->bSlot);
|
sc_error(ctx, "Received request to invalid slot (bSlot=0x%02x)", request->bSlot);
|
||||||
goto err;
|
goto err;
|
||||||
@@ -1218,7 +1220,9 @@ perform_PC_to_RDR_Secure(const __u8 *in, size_t inlen, __u8** out, size_t *outle
|
|||||||
|
|
||||||
sc_result = get_rapdu(&apdu, request->bSlot, &abDataOut, &abDataOutLen);
|
sc_result = get_rapdu(&apdu, request->bSlot, &abDataOut, &abDataOutLen);
|
||||||
|
|
||||||
sc_mem_clear(abPINApdu, apdulen);
|
/* clear PINs that have been transmitted */
|
||||||
|
sc_mem_clear((u8 *) apdu.data, apdu.datalen);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (curr_pin.data) {
|
if (curr_pin.data) {
|
||||||
sc_mem_clear((u8 *) curr_pin.data, curr_pin.len);
|
sc_mem_clear((u8 *) curr_pin.data, curr_pin.len);
|
||||||
@@ -1232,8 +1236,7 @@ err:
|
|||||||
sc_result = get_RDR_to_PC_DataBlock(request->bSlot, request->bSeq, sc_result, out,
|
sc_result = get_RDR_to_PC_DataBlock(request->bSlot, request->bSeq, sc_result, out,
|
||||||
outlen, abDataOut, abDataOutLen);
|
outlen, abDataOut, abDataOutLen);
|
||||||
|
|
||||||
if (abDataOut)
|
free(abDataOut);
|
||||||
free(abDataOut);
|
|
||||||
|
|
||||||
return sc_result;
|
return sc_result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user