From 78fd66c8b57709038b12d2f8f86dbfd3ffd1cba7 Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Tue, 24 Apr 2012 12:10:44 +0000 Subject: [PATCH] fixed clang --analyze warnings git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@780 96b47cad-a561-4643-ad3b-153ac7d7599c --- ccid/src/ccid.c | 19 +++++++++---------- npa/src/npa.c | 8 ++++++-- virtualsmartcard/src/vpcd/ifd-vpcd.c | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ccid/src/ccid.c b/ccid/src/ccid.c index 3d1e6e5..1d45f27 100644 --- a/ccid/src/ccid.c +++ b/ccid/src/ccid.c @@ -420,7 +420,7 @@ static int perform_PC_to_RDR_IccPowerOff(const __u8 *in, size_t inlen, __u8 **out, size_t *outlen) { const PC_to_RDR_IccPowerOff_t *request = (PC_to_RDR_IccPowerOff_t *) in; - int sc_result; + int sc_result = SC_SUCCESS; if (!in || !out || !outlen) return SC_ERROR_INVALID_ARGUMENTS; @@ -636,15 +636,14 @@ perform_PC_to_RDR_GetParamters(const __u8 *in, size_t inlen, __u8** out, size_t break; default: - goto invaliddata; + sc_result = SC_ERROR_INVALID_DATA; + break; } -invaliddata: - result = realloc(*out, sizeof *result); - if (!result) - return SC_ERROR_OUT_OF_MEMORY; - *out = (__u8 *) result; - sc_result = SC_ERROR_INVALID_DATA; + result = realloc(*out, sizeof *result); + if (!result) + return SC_ERROR_OUT_OF_MEMORY; + *out = (__u8 *) result; result->bMessageType = 0x82; result->bSlot = 0; @@ -930,7 +929,6 @@ perform_PC_to_RDR_Secure_EstablishPACEChannel(sc_card_t *card, goto err; } pace_input.certificate_description = &abData[parsed]; - parsed += pace_input.certificate_description_length; if (pace_input.certificate_description_length) { bin_log(ctx, SC_LOG_DEBUG_VERBOSE, "Certificate description", pace_input.certificate_description, @@ -1044,7 +1042,6 @@ perform_PC_to_RDR_Secure_EstablishPACEChannel(sc_card_t *card, /* Flawfinder: ignore */ memcpy(p, pace_output.id_icc, pace_output.id_icc_length); - p += pace_output.id_icc_length; *abDataOutLen = @@ -1680,6 +1677,8 @@ int ccid_parse_control(struct usb_ctrlrequest *setup, __u8 **outbuf) r = SC_ERROR_NOT_SUPPORTED; } + } else { + r = SC_ERROR_INVALID_ARGUMENTS; } if (r < 0) diff --git a/npa/src/npa.c b/npa/src/npa.c index 48f71c2..e397af8 100644 --- a/npa/src/npa.c +++ b/npa/src/npa.c @@ -1589,7 +1589,9 @@ npa_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx, NPA_MSE_SET_AT_C *msesetat = NULL; const unsigned char *p; - if (!card || !ctx || !apdu || !ctx->priv_data) { + if (!card) + return SC_ERROR_INVALID_ARGUMENTS; + if(!ctx || !apdu || !ctx->priv_data) { r = SC_ERROR_INVALID_ARGUMENTS; goto err; } @@ -1787,7 +1789,9 @@ static int npa_sm_finish(sc_card_t *card, const struct sm_ctx *ctx, sc_apdu_t *apdu) { - if (!card || !ctx || !ctx->priv_data || !apdu || !card) + if (!card) + return SC_ERROR_INVALID_ARGUMENTS; + if(!ctx || !ctx->priv_data || !apdu) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); struct npa_sm_ctx *eacsmctx = ctx->priv_data; diff --git a/virtualsmartcard/src/vpcd/ifd-vpcd.c b/virtualsmartcard/src/vpcd/ifd-vpcd.c index caf7a43..1673632 100644 --- a/virtualsmartcard/src/vpcd/ifd-vpcd.c +++ b/virtualsmartcard/src/vpcd/ifd-vpcd.c @@ -202,7 +202,7 @@ IFDHTransmitToICC (DWORD Lun, SCARD_IO_HEADER SendPci, PUCHAR TxBuffer, (*RxLength) = size; /* Flawfinder: ignore */ - RxBuffer = memcpy(RxBuffer, rapdu, size); + memcpy(RxBuffer, rapdu, size); free(rapdu); RecvPci->Protocol = 1;