made sc_apdu_t.data 'const' (which it used to be)
fixes a lot of warnings which pass a const buffer to the APDU's data Note that a non-const data member is only required for sc_allocate_apdu sc_free_apdu. They are currently used with an explicit typecast. However, sc_allocate_apdu and sc_free_apdu both are not used once in the entire project. One might also simply throw both functions away. -- Both are thrown away. (VT)
This commit is contained in:
parent
2c019485e8
commit
07818329ab
|
@ -61,55 +61,6 @@ void sc_format_apdu(sc_card_t *card, sc_apdu_t *apdu,
|
|||
apdu->p2 = (u8) p2;
|
||||
}
|
||||
|
||||
struct sc_apdu *
|
||||
sc_allocate_apdu(struct sc_apdu *copy_from, unsigned flags)
|
||||
{
|
||||
struct sc_apdu *apdu = NULL;
|
||||
|
||||
assert(copy_from != NULL);
|
||||
apdu = (struct sc_apdu *)malloc(sizeof(struct sc_apdu));
|
||||
if (!copy_from || !apdu)
|
||||
return apdu;
|
||||
memcpy(apdu, copy_from, sizeof(struct sc_apdu));
|
||||
apdu->data = apdu->resp = NULL;
|
||||
apdu->next = NULL;
|
||||
apdu->datalen = apdu->resplen = 0;
|
||||
apdu->allocation_flags = SC_APDU_ALLOCATE_FLAG;
|
||||
|
||||
if ((flags & SC_APDU_ALLOCATE_FLAG_DATA) && copy_from->data && copy_from->datalen) {
|
||||
apdu->data = malloc(copy_from->datalen);
|
||||
if (!apdu->data)
|
||||
return NULL;
|
||||
memcpy(apdu->data, copy_from->data, copy_from->datalen);
|
||||
apdu->datalen = copy_from->datalen;
|
||||
apdu->allocation_flags |= SC_APDU_ALLOCATE_FLAG_DATA;
|
||||
}
|
||||
|
||||
if ((flags & SC_APDU_ALLOCATE_FLAG_RESP) && copy_from->resp && copy_from->resplen) {
|
||||
apdu->resp = malloc(copy_from->resplen);
|
||||
if (!apdu->resp)
|
||||
return NULL;
|
||||
memcpy(apdu->resp, copy_from->resp, copy_from->resplen);
|
||||
apdu->resplen = copy_from->resplen;
|
||||
apdu->allocation_flags |= SC_APDU_ALLOCATE_FLAG_RESP;
|
||||
}
|
||||
return apdu;
|
||||
}
|
||||
|
||||
void
|
||||
sc_free_apdu(struct sc_apdu *apdu)
|
||||
{
|
||||
if (!apdu)
|
||||
return;
|
||||
if (apdu->allocation_flags & SC_APDU_ALLOCATE_FLAG_DATA)
|
||||
free (apdu->data);
|
||||
if (apdu->allocation_flags & SC_APDU_ALLOCATE_FLAG_RESP)
|
||||
free (apdu->resp);
|
||||
if (apdu->allocation_flags & SC_APDU_ALLOCATE_FLAG)
|
||||
free (apdu);
|
||||
}
|
||||
|
||||
|
||||
static sc_card_t * sc_card_new(sc_context_t *ctx)
|
||||
{
|
||||
sc_card_t *card;
|
||||
|
|
|
@ -99,8 +99,6 @@ sc_file_set_sec_attr
|
|||
sc_file_set_type_attr
|
||||
sc_file_valid
|
||||
sc_format_apdu
|
||||
sc_allocate_apdu
|
||||
sc_free_apdu
|
||||
sc_bytes2apdu
|
||||
sc_format_asn1_entry
|
||||
sc_format_oid
|
||||
|
|
|
@ -726,9 +726,6 @@ void sc_format_apdu(struct sc_card *, struct sc_apdu *, int, int, int, int);
|
|||
|
||||
int sc_check_apdu(struct sc_card *, const struct sc_apdu *);
|
||||
|
||||
struct sc_apdu *sc_allocate_apdu(struct sc_apdu *, unsigned);
|
||||
void sc_free_apdu(struct sc_apdu *);
|
||||
|
||||
/** Transforms an APDU from binary to its @c sc_apdu_t representation
|
||||
* @param ctx sc_context_t object (used for logging)
|
||||
* @param buf APDU to be encoded as an @c sc_apdu_t object
|
||||
|
|
|
@ -280,7 +280,7 @@ typedef struct sc_apdu {
|
|||
int cse; /* APDU case */
|
||||
unsigned char cla, ins, p1, p2; /* CLA, INS, P1 and P2 bytes */
|
||||
size_t lc, le; /* Lc and Le bytes */
|
||||
unsigned char *data; /* C-APDU data */
|
||||
const unsigned char *data; /* C-APDU data */
|
||||
size_t datalen; /* length of data in C-APDU */
|
||||
unsigned char *resp; /* R-APDU data buffer */
|
||||
size_t resplen; /* in: size of R-APDU buffer,
|
||||
|
|
Loading…
Reference in New Issue