Use strlcpy(3), strlcat(3) in pkcs15-itacns.c
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4635 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
b279287701
commit
d37dd91b63
|
@ -38,6 +38,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "common/compat_strlcpy.h"
|
#include "common/compat_strlcpy.h"
|
||||||
|
#include "common/compat_strlcat.h"
|
||||||
|
|
||||||
#ifdef ENABLE_OPENSSL
|
#ifdef ENABLE_OPENSSL
|
||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
|
@ -536,25 +537,20 @@ static int itacns_add_keyset(sc_pkcs15_card_t *p15card,
|
||||||
|
|
||||||
/* PIN and PUK */
|
/* PIN and PUK */
|
||||||
char pinlabel[16];
|
char pinlabel[16];
|
||||||
{
|
strlcpy(pinlabel, "PIN ", sizeof(pinlabel));
|
||||||
const char PIN[] = "PIN ";
|
strlcat(pinlabel, label, sizeof(pinlabel));
|
||||||
strcpy(pinlabel, PIN);
|
|
||||||
strncat(pinlabel, label, sizeof(pinlabel)-sizeof(PIN)-1);
|
|
||||||
}
|
|
||||||
/* We are making up ID 0x90+ to link the PIN and the PUK. */
|
/* We are making up ID 0x90+ to link the PIN and the PUK. */
|
||||||
int fake_puk_authid = 0x90 + pin_ref;
|
int fake_puk_authid = 0x90 + pin_ref;
|
||||||
int pin_flags = SC_PKCS15_PIN_FLAG_CASE_SENSITIVE
|
int pin_flags = SC_PKCS15_PIN_FLAG_CASE_SENSITIVE
|
||||||
| SC_PKCS15_PIN_FLAG_INITIALIZED;
|
| SC_PKCS15_PIN_FLAG_INITIALIZED;
|
||||||
|
|
||||||
r = itacns_add_pin(p15card, pinlabel, sec_env, fake_puk_authid, pin_ref,
|
r = itacns_add_pin(p15card, pinlabel, sec_env, fake_puk_authid, pin_ref,
|
||||||
private_path, pin_flags);
|
private_path, pin_flags);
|
||||||
SC_TEST_RET(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_RET(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
||||||
"Could not add PIN");
|
"Could not add PIN");
|
||||||
{
|
|
||||||
const char PUK[] = "PUK ";
|
strlcpy(pinlabel, "PUK ", sizeof(pinlabel));
|
||||||
strcpy(pinlabel, PUK);
|
strlcat(pinlabel, label, sizeof(pinlabel));
|
||||||
strncat(pinlabel, label, sizeof(pinlabel)-sizeof(PUK)-1);
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Looking at pkcs15-tcos.c and pkcs15-framework.c, it seems that the
|
* Looking at pkcs15-tcos.c and pkcs15-framework.c, it seems that the
|
||||||
* right thing to do here is to define a PUK as a SO PIN. Can anybody
|
* right thing to do here is to define a PUK as a SO PIN. Can anybody
|
||||||
|
|
Loading…
Reference in New Issue