added compatibility to mingw
git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@408 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -77,7 +77,7 @@ AC_TYPE_UINT8_T
|
|||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_MALLOC
|
AC_FUNC_MALLOC
|
||||||
AC_FUNC_REALLOC
|
AC_FUNC_REALLOC
|
||||||
AC_CHECK_FUNCS([memmove memset strerror])
|
AC_CHECK_FUNCS([getline memmove memset strerror])
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,25 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifndef HAVE_GETLINE
|
||||||
|
static ssize_t getline(char **lineptr, size_t *n, FILE *stream)
|
||||||
|
{
|
||||||
|
if (!lineptr)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
char *p = realloc(*lineptr, SC_MAX_EXT_APDU_BUFFER_SIZE*3);
|
||||||
|
if (!p)
|
||||||
|
return -1;
|
||||||
|
*lineptr = p;
|
||||||
|
|
||||||
|
if (fgets(p, SC_MAX_EXT_APDU_BUFFER_SIZE*3, stream) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return strlen(p);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
static int doinfo = 0;
|
static int doinfo = 0;
|
||||||
|
|||||||
@@ -907,7 +907,9 @@ npa_reset_retry_counter(struct sm_ctx *ctx, sc_card_t *card,
|
|||||||
free(p);
|
free(p);
|
||||||
return SC_ERROR_INTERNAL;
|
return SC_ERROR_INTERNAL;
|
||||||
}
|
}
|
||||||
new_len = strnlen(p, MAX_PIN_LEN+1);
|
new_len = strlen(p);
|
||||||
|
if (new_len > MAX_PIN_LEN)
|
||||||
|
return SC_ERROR_INVALID_PIN_LENGTH;
|
||||||
new = p;
|
new = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -952,7 +954,7 @@ get_psec(sc_card_t *card, const char *pin, size_t length_pin, enum s_type pin_id
|
|||||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not create password prompt.\n");
|
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not create password prompt.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = malloc(MAX_MRZ_LEN);
|
p = malloc(MAX_MRZ_LEN+1);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Not enough memory for %s.\n",
|
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Not enough memory for %s.\n",
|
||||||
npa_secret_name(pin_id));
|
npa_secret_name(pin_id));
|
||||||
@@ -963,7 +965,11 @@ get_psec(sc_card_t *card, const char *pin, size_t length_pin, enum s_type pin_id
|
|||||||
npa_secret_name(pin_id));
|
npa_secret_name(pin_id));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
length_pin = strnlen(p, MAX_MRZ_LEN);
|
length_pin = strlen(p);
|
||||||
|
if (length_pin > MAX_MRZ_LEN) {
|
||||||
|
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "MRZ too long");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
pin = p;
|
pin = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user