Skip to content

Commit

Permalink
Fix log messages format and parameter issues flagged by GCC
Browse files Browse the repository at this point in the history
Since "Add GCC format checking attributes to log functions" commit GCC
warns us about problems with format strings and their arguments provided
to OpenSC message logging functions.

This commit fixes all cases where GCC warned about incorrect format on
64-bit Linux, 32-bit and 64-bit mingw builds (with SM and OpenSSL enabled).
Well, almost all since on mingw GCC does not recognize "ll" size specifier
(present at least since Visual Studio 2005, also in mingw own CRT) so these
(few) warnings about it remain.

In most cases format size specifier for size_t type was missing (usually
size was left at default int level, with is different on 64-bit x86).
Some formats had too few / too many arguments.
In some cases pointers were printed as integers.
Some long variables were missing "l" prefix (especially with regard to %x
format).

Signed-off-by: Maciej S. Szmigiero <[email protected]>
  • Loading branch information
maciejsszmigiero committed Aug 26, 2016
1 parent 4c884b4 commit 9e7c901
Show file tree
Hide file tree
Showing 76 changed files with 972 additions and 496 deletions.
29 changes: 19 additions & 10 deletions src/libopensc/apdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,10 @@ sc_single_transmit(struct sc_card *card, struct sc_apdu *apdu)
if (card->reader->ops->transmit == NULL)
LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "cannot transmit APDU");

sc_log(ctx, "CLA:%X, INS:%X, P1:%X, P2:%X, data(%i) %p",
apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen, apdu->data);
sc_log(ctx,
"CLA:%X, INS:%X, P1:%X, P2:%X, data(%"SC_FORMAT_LEN_SIZE_T"u) %p",
apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen,
apdu->data);
#ifdef ENABLE_SM
if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT)
return sc_sm_single_transmit(card, apdu);
Expand Down Expand Up @@ -659,8 +661,9 @@ sc_bytes2apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)

if (!len) {
apdu->cse = SC_APDU_CASE_1;
sc_log(ctx, "CASE_1 APDU: %lu bytes:\tins=%02x p1=%02x p2=%02x lc=%04x le=%04x",
(unsigned long) len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le);
sc_log(ctx,
"CASE_1 APDU: %"SC_FORMAT_LEN_SIZE_T"u bytes:\tins=%02x p1=%02x p2=%02x lc=%04"SC_FORMAT_LEN_SIZE_T"x le=%04"SC_FORMAT_LEN_SIZE_T"x",
len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le);
return SC_SUCCESS;
}

Expand All @@ -681,7 +684,9 @@ sc_bytes2apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
apdu->lc += *p++;
len -= 3;
if (len < apdu->lc) {
sc_log(ctx, "APDU too short (need %lu more bytes)", (unsigned long) apdu->lc - len);
sc_log(ctx,
"APDU too short (need %"SC_FORMAT_LEN_SIZE_T"u more bytes)",
apdu->lc - len);
return SC_ERROR_INVALID_DATA;
}
apdu->data = p;
Expand Down Expand Up @@ -719,7 +724,9 @@ sc_bytes2apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
apdu->lc = *p++;
len--;
if (len < apdu->lc) {
sc_log(ctx, "APDU too short (need %lu more bytes)", (unsigned long) apdu->lc - len);
sc_log(ctx,
"APDU too short (need %"SC_FORMAT_LEN_SIZE_T"u more bytes)",
apdu->lc - len);
return SC_ERROR_INVALID_DATA;
}
apdu->data = p;
Expand All @@ -743,10 +750,12 @@ sc_bytes2apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
return SC_ERROR_INVALID_DATA;
}

sc_log(ctx, "Case %d %s APDU, %lu bytes:\tins=%02x p1=%02x p2=%02x lc=%04x le=%04x",
apdu->cse & SC_APDU_SHORT_MASK,
(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
(unsigned long) len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le);
sc_log(ctx,
"Case %d %s APDU, %"SC_FORMAT_LEN_SIZE_T"u bytes:\tins=%02x p1=%02x p2=%02x lc=%04"SC_FORMAT_LEN_SIZE_T"x le=%04"SC_FORMAT_LEN_SIZE_T"x",
apdu->cse & SC_APDU_SHORT_MASK,
(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc,
apdu->le);

return SC_SUCCESS;
}
33 changes: 20 additions & 13 deletions src/libopensc/asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,9 @@ const u8 *sc_asn1_skip_tag(sc_context_t *ctx, const u8 ** buf, size_t *buflen,
return NULL;
len -= (p - *buf); /* header size */
if (taglen > len) {
sc_debug(ctx, SC_LOG_DEBUG_ASN1, "too long ASN.1 object (size %d while only %d available)\n",
taglen, len);
sc_debug(ctx, SC_LOG_DEBUG_ASN1,
"too long ASN.1 object (size %"SC_FORMAT_LEN_SIZE_T"u while only %"SC_FORMAT_LEN_SIZE_T"u available)\n",
taglen, len);
return NULL;
}
*buflen -= (p - *buf) + taglen;
Expand Down Expand Up @@ -1273,7 +1274,9 @@ static int asn1_decode_entry(sc_context_t *ctx,struct sc_asn1_entry *entry,
case SC_ASN1_BOOLEAN:
if (parm != NULL) {
if (objlen != 1) {
sc_debug(ctx, SC_LOG_DEBUG_ASN1, "invalid ASN.1 object length: %d\n", objlen);
sc_debug(ctx, SC_LOG_DEBUG_ASN1,
"invalid ASN.1 object length: %"SC_FORMAT_LEN_SIZE_T"u\n",
objlen);
r = SC_ERROR_INVALID_ASN1_OBJECT;
} else
*((int *) parm) = obj[0] ? 1 : 0;
Expand Down Expand Up @@ -1441,10 +1444,9 @@ static int asn1_decode(sc_context_t *ctx, struct sc_asn1_entry *asn1,
struct sc_asn1_entry *entry = asn1;
size_t left = len, objlen;

sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*scalled, left=%u, depth %d%s\n",
depth, depth, "",
left, depth,
choice ? ", choice" : "");
sc_debug(ctx, SC_LOG_DEBUG_ASN1,
"%*.*scalled, left=%"SC_FORMAT_LEN_SIZE_T"u, depth %d%s\n",
depth, depth, "", left, depth, choice ? ", choice" : "");

if (!p)
return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
Expand Down Expand Up @@ -1550,9 +1552,10 @@ static int asn1_encode_entry(sc_context_t *ctx, const struct sc_asn1_entry *entr
(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
if (!(entry->flags & SC_ASN1_PRESENT))
goto no_object;
sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*stype=%d, tag=0x%02x, parm=%p, len=%u\n",
depth, depth, "",
entry->type, entry->tag, parm, len? *len : 0);
sc_debug(ctx, SC_LOG_DEBUG_ASN1,
"%*.*stype=%d, tag=0x%02x, parm=%p, len=%"SC_FORMAT_LEN_SIZE_T"u\n",
depth, depth, "", entry->type, entry->tag, parm,
len ? *len : 0);

if (entry->type == SC_ASN1_CHOICE) {
const struct sc_asn1_entry *list, *choice = NULL;
Expand Down Expand Up @@ -1730,7 +1733,9 @@ static int asn1_encode_entry(sc_context_t *ctx, const struct sc_asn1_entry *entr
if (buf)
free(buf);
if (r >= 0)
sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*slength of encoded item=%u\n", depth, depth, "", *objlen);
sc_debug(ctx, SC_LOG_DEBUG_ASN1,
"%*.*slength of encoded item=%"SC_FORMAT_LEN_SIZE_T"u\n",
depth, depth, "", *objlen);
return r;
}

Expand Down Expand Up @@ -1913,8 +1918,10 @@ sc_asn1_sig_value_sequence_to_rs(struct sc_context *ctx, unsigned char *in, size
memcpy(buf + (halflen - r_len), r, r_len);
memcpy(buf + (buflen - s_len), s, s_len);

sc_log(ctx, "r(%i): %s", halflen, sc_dump_hex(buf, halflen));
sc_log(ctx, "s(%i): %s", halflen, sc_dump_hex(buf + halflen, halflen));
sc_log(ctx, "r(%"SC_FORMAT_LEN_SIZE_T"u): %s", halflen,
sc_dump_hex(buf, halflen));
sc_log(ctx, "s(%"SC_FORMAT_LEN_SIZE_T"u): %s", halflen,
sc_dump_hex(buf + halflen, halflen));

rv = SC_SUCCESS;
done:
Expand Down
4 changes: 3 additions & 1 deletion src/libopensc/aux-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ sc_aux_data_get_md_guid(struct sc_context *ctx, struct sc_auxiliary_data *aux_da
strlcat(guid, "}", sizeof(guid));

if (*out_size < strlen(guid)) {
sc_log(ctx, "aux-data: buffer too small: out_size:%i < guid-length:%i", *out_size, strlen(guid));
sc_log(ctx,
"aux-data: buffer too small: out_size:%"SC_FORMAT_LEN_SIZE_T"u < guid-length:%"SC_FORMAT_LEN_SIZE_T"u",
*out_size, strlen(guid));
LOG_FUNC_RETURN(ctx, SC_ERROR_BUFFER_TOO_SMALL);
}

Expand Down
11 changes: 6 additions & 5 deletions src/libopensc/card-atrust-acos.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,12 @@ static int atrust_acos_select_file(struct sc_card *card,
pbuf[0] = '\0';

sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
"current path (%s, %s): %s (len: %u)\n",
(card->cache.current_path.type==SC_PATH_TYPE_DF_NAME?"aid":"path"),
(card->cache.valid?"valid":"invalid"), pbuf,
card->cache.current_path.len);

"current path (%s, %s): %s (len: %"SC_FORMAT_LEN_SIZE_T"u)\n",
card->cache.current_path.type == SC_PATH_TYPE_DF_NAME ?
"aid" : "path",
card->cache.valid ? "valid" : "invalid", pbuf,
card->cache.current_path.len);

memcpy(path, in_path->value, in_path->len);
pathlen = in_path->len;

Expand Down
79 changes: 52 additions & 27 deletions src/libopensc/card-authentic.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ authentic_parse_credential_data(struct sc_context *ctx, struct sc_pin_cmd_data *

rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_DOCP_ACLS, &data, &data_len);
LOG_TEST_RET(ctx, rv, "failed to get ACLs");
sc_log(ctx, "data_len:%i", data_len);
sc_log(ctx, "data_len:%"SC_FORMAT_LEN_SIZE_T"u", data_len);
if (data_len == 10) {
for (ii=0; ii<5; ii++) {
unsigned char acl = *(data + ii*2);
Expand Down Expand Up @@ -862,14 +862,16 @@ authentic_read_binary(struct sc_card *card, unsigned int idx,
int rv;

LOG_FUNC_CALLED(ctx);
sc_log(ctx, "offs:%i,count:%i,max_recv_size:%i", idx, count, card->max_recv_size);
sc_log(ctx,
"offs:%i,count:%"SC_FORMAT_LEN_SIZE_T"u,max_recv_size:%"SC_FORMAT_LEN_SIZE_T"u",
idx, count, card->max_recv_size);

/* Data size more then 256 bytes can happen when card reader is
* configurated with max_send/recv_size more then 255/256 bytes
* (for ex. 'remote-access' reader) .
* In this case create chained 'read-binary' APDUs.
*/
sc_log(ctx, "reader flags 0x%X", card->reader->flags);
sc_log(ctx, "reader flags 0x%lX", card->reader->flags);
if (count > 256 && !(card->reader->flags & SC_READER_HAS_WAITING_AREA))
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid size of the data to read");

Expand Down Expand Up @@ -916,10 +918,12 @@ authentic_write_binary(struct sc_card *card, unsigned int idx,
int rv;

LOG_FUNC_CALLED(ctx);
sc_log(ctx, "offs:%i,count:%i,max_send_size:%i", idx, count, card->max_send_size);
sc_log(ctx,
"offs:%i,count:%"SC_FORMAT_LEN_SIZE_T"u,max_send_size:%"SC_FORMAT_LEN_SIZE_T"u",
idx, count, card->max_send_size);

/* see comments for authentic_read_binary() */
sc_log(ctx, "reader flags 0x%X", card->reader->flags);
sc_log(ctx, "reader flags 0x%lX", card->reader->flags);
if (count > 255 && !(card->reader->flags & SC_READER_HAS_WAITING_AREA))
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid size of the data to read");

Expand Down Expand Up @@ -965,10 +969,12 @@ authentic_update_binary(struct sc_card *card, unsigned int idx,
int rv;

LOG_FUNC_CALLED(ctx);
sc_log(ctx, "offs:%i,count:%i,max_send_size:%i", idx, count, card->max_send_size);
sc_log(ctx,
"offs:%i,count:%"SC_FORMAT_LEN_SIZE_T"u,max_send_size:%"SC_FORMAT_LEN_SIZE_T"u",
idx, count, card->max_send_size);

/* see comments for authentic_read_binary() */
sc_log(ctx, "reader flags 0x%X", card->reader->flags);
sc_log(ctx, "reader flags 0x%lX", card->reader->flags);
if (count > 255 && !(card->reader->flags & SC_READER_HAS_WAITING_AREA))
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid size of the data to read");

Expand Down Expand Up @@ -1024,14 +1030,14 @@ authentic_process_fci(struct sc_card *card, struct sc_file *file,

tag = sc_asn1_find_tag(card->ctx, buf, buflen, 0x6F, &taglen);
if (tag != NULL) {
sc_log(ctx, " FCP length %i", taglen);
sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
buf = tag;
buflen = taglen;
}

tag = sc_asn1_find_tag(card->ctx, buf, buflen, 0x62, &taglen);
if (tag != NULL) {
sc_log(ctx, " FCP length %i", taglen);
sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
buf = tag;
buflen = taglen;
}
Expand All @@ -1040,7 +1046,9 @@ authentic_process_fci(struct sc_card *card, struct sc_file *file,
LOG_TEST_RET(ctx, rv, "ISO parse FCI failed");

if (!file->sec_attr_len) {
sc_log(ctx, "ACLs not found in data(%i) %s", buflen, sc_dump_hex(buf, buflen));
sc_log(ctx,
"ACLs not found in data(%"SC_FORMAT_LEN_SIZE_T"u) %s",
buflen, sc_dump_hex(buf, buflen));
sc_log(ctx, "Path:%s; Type:%X; PathType:%X", sc_print_path(&file->path), file->type, file->path.type);
if (file->path.type == SC_PATH_TYPE_DF_NAME || file->type == SC_FILE_TYPE_DF) {
file->type = SC_FILE_TYPE_DF;
Expand All @@ -1050,7 +1058,8 @@ authentic_process_fci(struct sc_card *card, struct sc_file *file,
}
}

sc_log(ctx, "ACL data(%i):%s", file->sec_attr_len, sc_dump_hex(file->sec_attr, file->sec_attr_len));
sc_log(ctx, "ACL data(%"SC_FORMAT_LEN_SIZE_T"u):%s", file->sec_attr_len,
sc_dump_hex(file->sec_attr, file->sec_attr_len));
for (ii = 0; ii < file->sec_attr_len / 2; ii++) {
unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii];
unsigned char acl = *(file->sec_attr + ii*2);
Expand Down Expand Up @@ -1423,10 +1432,14 @@ authentic_pin_change_pinpad(struct sc_card *card, unsigned reference, int *tries
memset(pin2_data, pin_cmd.pin2.pad_char, sizeof(pin2_data));
pin_cmd.pin2.data = pin2_data;

sc_log(ctx, "PIN1 lengths max/min/pad: %i/%i/%i", pin_cmd.pin1.max_length, pin_cmd.pin1.min_length,
pin_cmd.pin1.pad_length);
sc_log(ctx, "PIN2 lengths max/min/pad: %i/%i/%i", pin_cmd.pin2.max_length, pin_cmd.pin2.min_length,
pin_cmd.pin2.pad_length);
sc_log(ctx,
"PIN1 lengths max/min/pad: %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u",
pin_cmd.pin1.max_length, pin_cmd.pin1.min_length,
pin_cmd.pin1.pad_length);
sc_log(ctx,
"PIN2 lengths max/min/pad: %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u",
pin_cmd.pin2.max_length, pin_cmd.pin2.min_length,
pin_cmd.pin2.pad_length);

rv = iso_ops->pin_cmd(card, &pin_cmd, tries_left);

Expand Down Expand Up @@ -1516,8 +1529,10 @@ authentic_chv_set_pinpad(struct sc_card *card, unsigned char reference)
memcpy(&pin_cmd.pin2, &pin_cmd.pin1, sizeof(pin_cmd.pin1));
memset(&pin_cmd.pin1, 0, sizeof(pin_cmd.pin1));

sc_log(ctx, "PIN2 max/min/pad %i/%i/%i",
pin_cmd.pin2.max_length, pin_cmd.pin2.min_length, pin_cmd.pin2.pad_length);
sc_log(ctx,
"PIN2 max/min/pad %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u",
pin_cmd.pin2.max_length, pin_cmd.pin2.min_length,
pin_cmd.pin2.pad_length);
rv = iso_ops->pin_cmd(card, &pin_cmd, NULL);

LOG_FUNC_RETURN(ctx, rv);
Expand Down Expand Up @@ -1565,9 +1580,11 @@ authentic_pin_get_policy (struct sc_card *card, struct sc_pin_cmd_data *data)

data->flags |= SC_PIN_CMD_NEED_PADDING;

sc_log(ctx, "PIN policy: size max/min/pad %i/%i/%i, tries max/left %i/%i",
data->pin1.max_length, data->pin1.min_length, data->pin1.pad_length,
data->pin1.max_tries, data->pin1.tries_left);
sc_log(ctx,
"PIN policy: size max/min/pad %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u, tries max/left %i/%i",
data->pin1.max_length, data->pin1.min_length,
data->pin1.pad_length, data->pin1.max_tries,
data->pin1.tries_left);

LOG_FUNC_RETURN(ctx, rv);
}
Expand Down Expand Up @@ -1796,11 +1813,15 @@ authentic_manage_sdo_encode_prvkey(struct sc_card *card, struct sc_pkcs15_prkey
blob_len = 0;

/* Encode public RSA key part */
sc_log(ctx, "modulus.len:%i blob_len:%i", rsa.modulus.len, blob_len);
sc_log(ctx,
"modulus.len:%"SC_FORMAT_LEN_SIZE_T"u blob_len:%"SC_FORMAT_LEN_SIZE_T"u",
rsa.modulus.len, blob_len);
rv = authentic_update_blob(ctx, AUTHENTIC_TAG_RSA_PUBLIC_MODULUS, rsa.modulus.data, rsa.modulus.len, &blob, &blob_len);
LOG_TEST_RET(ctx, rv, "SDO RSA Modulus encode error");

sc_log(ctx, "exponent.len:%i blob_len:%i", rsa.exponent.len, blob_len);
sc_log(ctx,
"exponent.len:%"SC_FORMAT_LEN_SIZE_T"u blob_len:%"SC_FORMAT_LEN_SIZE_T"u",
rsa.exponent.len, blob_len);
rv = authentic_update_blob(ctx, AUTHENTIC_TAG_RSA_PUBLIC_EXPONENT, rsa.exponent.data, rsa.exponent.len, &blob, &blob_len);
LOG_TEST_RET(ctx, rv, "SDO RSA Exponent encode error");

Expand Down Expand Up @@ -1912,7 +1933,7 @@ authentic_manage_sdo_generate(struct sc_card *card, struct sc_authentic_sdo *sdo

rv = authentic_manage_sdo_encode(card, sdo, SC_CARDCTL_AUTHENTIC_SDO_GENERATE, &data, &data_len);
LOG_TEST_RET(ctx, rv, "Cannot encode SDO data");
sc_log(ctx, "encoded SDO length %i", data_len);
sc_log(ctx, "encoded SDO length %"SC_FORMAT_LEN_SIZE_T"u", data_len);

sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x47, 0x00, 0x00);
apdu.data = data;
Expand Down Expand Up @@ -1949,7 +1970,7 @@ authentic_manage_sdo(struct sc_card *card, struct sc_authentic_sdo *sdo, unsigne

rv = authentic_manage_sdo_encode(card, sdo, cmd, &data, &data_len);
LOG_TEST_RET(ctx, rv, "Cannot encode SDO data");
sc_log(ctx, "encoded SDO length %i", data_len);
sc_log(ctx, "encoded SDO length %"SC_FORMAT_LEN_SIZE_T"u", data_len);

sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDB, 0x3F, 0xFF);
apdu.data = data;
Expand Down Expand Up @@ -2053,7 +2074,9 @@ authentic_decipher(struct sc_card *card, const unsigned char *in, size_t in_len,
int rv;

LOG_FUNC_CALLED(ctx);
sc_log(ctx, "crgram_len %i; outlen %i", in_len, out_len);
sc_log(ctx,
"crgram_len %"SC_FORMAT_LEN_SIZE_T"u; outlen %"SC_FORMAT_LEN_SIZE_T"u",
in_len, out_len);
if (!out || !out_len || in_len > SC_MAX_APDU_BUFFER_SIZE)
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);

Expand Down Expand Up @@ -2262,8 +2285,10 @@ authentic_sm_get_wrapped_apdu(struct sc_card *card, struct sc_apdu *plain, struc

if (!plain || !sm_apdu)
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
sc_log(ctx, "called; CLA:%X, INS:%X, P1:%X, P2:%X, data(%i) %p",
plain->cla, plain->ins, plain->p1, plain->p2, plain->datalen, plain->data);
sc_log(ctx,
"called; CLA:%X, INS:%X, P1:%X, P2:%X, data(%"SC_FORMAT_LEN_SIZE_T"u) %p",
plain->cla, plain->ins, plain->p1, plain->p2, plain->datalen,
plain->data);
*sm_apdu = NULL;

if ((plain->cla & 0x04)
Expand Down
4 changes: 3 additions & 1 deletion src/libopensc/card-belpic.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,9 @@ static int get_carddata(sc_card_t *card, u8* carddata_loc, unsigned int carddata
return r;
}
if(apdu.resplen < carddataloc_len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "GetCardData: card returned %d bytes rather than expected %d\n", apdu.resplen, carddataloc_len);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
"GetCardData: card returned %"SC_FORMAT_LEN_SIZE_T"u bytes rather than expected %d\n",
apdu.resplen, carddataloc_len);
return SC_ERROR_WRONG_LENGTH;
}

Expand Down
8 changes: 6 additions & 2 deletions src/libopensc/card-cardos.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,8 +1204,12 @@ cardos_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data,
data->pin_reference |= 0x80;

sc_log(ctx, "PIN_CMD(cmd:%i, ref:%i)", data->cmd, data->pin_reference);
sc_log(ctx, "PIN1(max:%i, min:%i)", data->pin1.max_length, data->pin1.min_length);
sc_log(ctx, "PIN2(max:%i, min:%i)", data->pin2.max_length, data->pin2.min_length);
sc_log(ctx,
"PIN1(max:%"SC_FORMAT_LEN_SIZE_T"u, min:%"SC_FORMAT_LEN_SIZE_T"u)",
data->pin1.max_length, data->pin1.min_length);
sc_log(ctx,
"PIN2(max:%"SC_FORMAT_LEN_SIZE_T"u, min:%"SC_FORMAT_LEN_SIZE_T"u)",
data->pin2.max_length, data->pin2.min_length);

/* FIXME: the following values depend on what pin length was
* used when creating the BS objects */
Expand Down
Loading

0 comments on commit 9e7c901

Please sign in to comment.