- lnfc: capdu was not copied, fixed
- changed some output messages git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@354 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -124,21 +124,21 @@ static int lnfc_connect(void **driver_data)
|
||||
*driver_data = data;
|
||||
|
||||
|
||||
// Try to open the NFC emulator device
|
||||
data->pndTarget = nfc_connect (NULL);
|
||||
if (data->pndTarget == NULL) {
|
||||
ERROR("Error connecting NFC emulator device\n");
|
||||
ERROR("Error connecting to NFC emulator device\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
INFO("Connected to the NFC emulator device: %s\n", data->pndTarget->acName);
|
||||
if (verbose >= 0)
|
||||
printf("Connected to %s\n", data->pndTarget->acName);
|
||||
|
||||
if (!nfc_target_init (data->pndTarget, &ntEmulatedTarget, data->abtCapdu, &data->szCapduLen)) {
|
||||
ERROR("Initialization of NFC emulator failed");
|
||||
nfc_disconnect (data->pndTarget);
|
||||
return 0;
|
||||
}
|
||||
DEBUG("%s\n", "Done, relaying frames now!");
|
||||
DEBUG("Initialized NFC emulator\n");
|
||||
|
||||
|
||||
return 1;
|
||||
@@ -159,6 +159,7 @@ static int lnfc_receive_capdu(void *driver_data,
|
||||
unsigned char **capdu, size_t *len)
|
||||
{
|
||||
struct lnfc_data *data = driver_data;
|
||||
unsigned char *p;
|
||||
|
||||
if (!data || !capdu || !len)
|
||||
return 0;
|
||||
@@ -172,6 +173,16 @@ static int lnfc_receive_capdu(void *driver_data,
|
||||
}
|
||||
|
||||
|
||||
p = realloc(*capdu, data->szCapduLen);
|
||||
if (!p) {
|
||||
ERROR("Error allocating memory for C-APDU\n");
|
||||
return 0;
|
||||
}
|
||||
memcpy(p, data->abtCapdu, data->szCapduLen);
|
||||
*capdu = p;
|
||||
*len = data->szCapduLen;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
struct picc_data {
|
||||
char *buf;
|
||||
size_t buflen;
|
||||
size_t bufmax;
|
||||
FILE *fd;
|
||||
};
|
||||
static int picc_encode_rapdu(const unsigned char *inbuf, size_t inlen,
|
||||
@@ -75,7 +75,6 @@ int picc_decode_apdu(const char *inbuf, size_t inlen,
|
||||
unsigned long int b;
|
||||
|
||||
if (!outbuf || !outlen) {
|
||||
/* Invalid parameters */
|
||||
return 0;
|
||||
}
|
||||
if (inbuf == NULL || inlen == 0 || inbuf[0] == '\0') {
|
||||
@@ -135,10 +134,11 @@ static int picc_connect(void **driver_data)
|
||||
}
|
||||
|
||||
data->buf = NULL;
|
||||
data->buflen = 0;
|
||||
data->bufmax = 0;
|
||||
|
||||
|
||||
INFO("Connected to %s\n", PICCDEV);
|
||||
if (verbose >= 0)
|
||||
printf("Connected to %s\n", PICCDEV);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ static int picc_disconnect(void *driver_data)
|
||||
data->fd = NULL;
|
||||
free(data->buf);
|
||||
data->buf = NULL;
|
||||
data->buflen = 0;
|
||||
data->bufmax = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -211,12 +211,12 @@ static int picc_send_rapdu(void *driver_data,
|
||||
/* encode R-APDU */
|
||||
if (!picc_encode_rapdu(rapdu, len, &data->buf, &buflen))
|
||||
return 0;
|
||||
if (data->buflen < buflen)
|
||||
data->buflen = buflen;
|
||||
if (data->bufmax < buflen)
|
||||
data->bufmax = buflen;
|
||||
|
||||
|
||||
/* write R-APDU */
|
||||
DEBUG("INF: Writing R-APDU\n\n%s\n\n", data->buf);
|
||||
DEBUG("INF: Writing R-APDU\r\n%s\r\n", data->buf);
|
||||
|
||||
if (fprintf(data->fd,"%s\r\n", (char *) data->buf) < 0
|
||||
|| fflush(data->fd) != 0) {
|
||||
|
||||
@@ -51,7 +51,7 @@ static const char *option_help[] = {
|
||||
"Print help and exit",
|
||||
"Number of reader to use (default: 0)",
|
||||
"Stay in foreground",
|
||||
"Emulation backend (openpicc [default], libnfc)",
|
||||
"NFC emulator backend (openpicc [default], libnfc)",
|
||||
"Use (several times) to be more verbose",
|
||||
};
|
||||
static int doinfo = 0;
|
||||
|
||||
Reference in New Issue
Block a user