- use strlcpy() instead of strncpy() to always have a terminating
NUL-byte - use sizeof(field) instead of SC_PKCS15_MAX_LABEL_SIZE-1 or equivalent as the 3rd argument of strlcpy() git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2993 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
382a7d6301
commit
126593aa01
|
@ -647,7 +647,7 @@ int belpic_set_language(const char *reader, int lang)
|
|||
lang_infos[i].reader[0] = '\0';
|
||||
} else { /* For only 1 reader */
|
||||
if (lang_infos[i].reader[0] == '\0') { /* reader not yet present */
|
||||
strncpy(lang_infos[i].reader, reader, MAX_READER_LEN - 1);
|
||||
strlcpy(lang_infos[i].reader, reader, sizeof(lang_infos[i].reader));
|
||||
lang_infos[i].lang = lang;
|
||||
break;
|
||||
} else if (strncmp(reader, lang_infos[i].reader, MAX_READER_LEN - 1) == 0) {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#include <zlib.h>
|
||||
|
@ -100,7 +101,7 @@ static int sc_pkcs15emu_add_pin(sc_pkcs15_card_t *p15card,
|
|||
if (type == SC_PKCS15_PIN_TYPE_BCD)
|
||||
info.stored_length /= 2;
|
||||
|
||||
strncpy(obj.label, label, SC_PKCS15_MAX_LABEL_SIZE-1);
|
||||
strlcpy(obj.label, label, sizeof(obj.label));
|
||||
obj.flags = obj_flags;
|
||||
|
||||
return sc_pkcs15emu_add_pin_obj(p15card, &obj, &info);
|
||||
|
@ -133,7 +134,7 @@ static int sc_pkcs15emu_add_prkey(sc_pkcs15_card_t *p15card,
|
|||
info.path = *path;
|
||||
|
||||
obj.flags = obj_flags;
|
||||
strncpy(obj.label, label, SC_PKCS15_MAX_LABEL_SIZE-1);
|
||||
strlcpy(obj.label, label, sizeof(obj.label));
|
||||
if (auth_id != NULL)
|
||||
obj.auth_id = *auth_id;
|
||||
|
||||
|
@ -242,7 +243,7 @@ static int sc_pkcs15emu_actalis_init(sc_pkcs15_card_t * p15card)
|
|||
cert_info.path = cpath;
|
||||
cert_info.authority = (i>0);
|
||||
|
||||
strncpy(cert_obj.label, certLabel[i], SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, certLabel[i], sizeof(cert_obj.label));
|
||||
cert_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE;
|
||||
|
||||
sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
#define MANU_ID "A-Trust"
|
||||
#define CARD_LABEL "a.sign Premium a"
|
||||
|
@ -214,7 +215,7 @@ static int sc_pkcs15emu_atrust_acos_init(sc_pkcs15_card_t *p15card)
|
|||
/* skip errors */
|
||||
continue;
|
||||
|
||||
strncpy(cert_obj.label, certs[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, certs[i].label, sizeof(cert_obj.label));
|
||||
cert_obj.flags = certs[i].obj_flags;
|
||||
|
||||
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
|
||||
|
@ -240,7 +241,7 @@ static int sc_pkcs15emu_atrust_acos_init(sc_pkcs15_card_t *p15card)
|
|||
sc_format_path(pins[i].path, &pin_info.path);
|
||||
pin_info.tries_left = -1;
|
||||
|
||||
strncpy(pin_obj.label, pins[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(pin_obj.label, pins[i].label, sizeof(pin_obj.label));
|
||||
pin_obj.flags = pins[i].obj_flags;
|
||||
|
||||
r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
|
||||
|
@ -262,7 +263,7 @@ static int sc_pkcs15emu_atrust_acos_init(sc_pkcs15_card_t *p15card)
|
|||
prkey_info.modulus_length= prkeys[i].modulus_len;
|
||||
sc_format_path(prkeys[i].path, &prkey_info.path);
|
||||
|
||||
strncpy(prkey_obj.label, prkeys[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(prkey_obj.label, prkeys[i].label, sizeof(prkey_obj.label));
|
||||
prkey_obj.flags = prkeys[i].obj_flags;
|
||||
if (prkeys[i].auth_id)
|
||||
sc_pkcs15_format_id(prkeys[i].auth_id, &prkey_obj.auth_id);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "esteid.h"
|
||||
#include "strlcpy.h"
|
||||
|
||||
int sc_pkcs15emu_esteid_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *);
|
||||
|
||||
|
@ -102,7 +103,7 @@ sc_pkcs15emu_esteid_init (sc_pkcs15_card_t * p15card)
|
|||
cert_info.id.value[0] = esteid_cert_ids[i];
|
||||
cert_info.id.len = 1;
|
||||
sc_format_path(esteid_cert_paths[i], &cert_info.path);
|
||||
strncpy(cert_obj.label, esteid_cert_names[i], SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, esteid_cert_names[i], sizeof(cert_obj.label));
|
||||
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
|
||||
if (r < 0)
|
||||
return SC_ERROR_INTERNAL;
|
||||
|
@ -148,7 +149,7 @@ sc_pkcs15emu_esteid_init (sc_pkcs15_card_t * p15card)
|
|||
pin_info.pad_char = '\0';
|
||||
pin_info.tries_left = (int)tries_left;
|
||||
|
||||
strncpy(pin_obj.label, esteid_pin_names[i], SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(pin_obj.label, esteid_pin_names[i], sizeof(pin_obj.label));
|
||||
pin_obj.flags = esteid_pin_flags[i];
|
||||
|
||||
/* Link normal PINs with PUK */
|
||||
|
@ -191,7 +192,7 @@ sc_pkcs15emu_esteid_init (sc_pkcs15_card_t * p15card)
|
|||
prkey_info.key_reference = i + 1;
|
||||
prkey_info.modulus_length= 1024;
|
||||
|
||||
strncpy(prkey_obj.label, prkey_name[i], SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(prkey_obj.label, prkey_name[i], sizeof(prkey_obj.label));
|
||||
prkey_obj.auth_id.len = 1;
|
||||
prkey_obj.auth_id.value[0] = prkey_pin[i];
|
||||
prkey_obj.user_consent = (i == 1) ? 1 : 0;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
#define MANU_ID "GemSAFE on GPK16000"
|
||||
|
||||
|
@ -338,7 +339,7 @@ static int sc_pkcs15emu_gemsafe_init(sc_pkcs15_card_t *p15card)
|
|||
sc_pkcs15_format_id(certs[i].id, &cert_info.id);
|
||||
cert_info.authority = certs[i].authority;
|
||||
|
||||
strncpy(cert_obj.label, certs[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, certs[i].label, sizeof(cert_obj.label));
|
||||
cert_obj.flags = certs[i].obj_flags;
|
||||
|
||||
while (idx1 < file->size - 16) { /* actually 13 for all these tests */
|
||||
|
@ -444,7 +445,7 @@ static int sc_pkcs15emu_gemsafe_init(sc_pkcs15_card_t *p15card)
|
|||
pin_info.path.value[3] = dfpath & 0xff;
|
||||
pin_info.tries_left = -1;
|
||||
|
||||
strncpy(pin_obj.label, pins[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(pin_obj.label, pins[i].label, sizeof(pin_obj.label));
|
||||
pin_obj.flags = pins[i].obj_flags;
|
||||
|
||||
r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
|
||||
|
@ -489,7 +490,7 @@ static int sc_pkcs15emu_gemsafe_init(sc_pkcs15_card_t *p15card)
|
|||
}
|
||||
}
|
||||
|
||||
strncpy(prkey_obj.label, prkeys[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(prkey_obj.label, prkeys[i].label, sizeof(prkey_obj.label));
|
||||
prkey_obj.flags = prkeys[i].obj_flags;
|
||||
if (prkeys[i].auth_id)
|
||||
sc_pkcs15_format_id(prkeys[i].auth_id, &prkey_obj.auth_id);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#include <zlib.h>
|
||||
|
@ -95,7 +96,7 @@ static int sc_pkcs15emu_add_pin(sc_pkcs15_card_t *p15card,
|
|||
if (type == SC_PKCS15_PIN_TYPE_BCD)
|
||||
info.stored_length /= 2;
|
||||
|
||||
strncpy(obj.label, label, SC_PKCS15_MAX_LABEL_SIZE-1);
|
||||
strlcpy(obj.label, label, sizeof(obj.label));
|
||||
obj.flags = obj_flags;
|
||||
|
||||
return sc_pkcs15emu_add_pin_obj(p15card, &obj, &info);
|
||||
|
@ -128,7 +129,7 @@ static int sc_pkcs15emu_add_prkey(sc_pkcs15_card_t *p15card,
|
|||
info.path = *path;
|
||||
|
||||
obj.flags = obj_flags;
|
||||
strncpy(obj.label, label, SC_PKCS15_MAX_LABEL_SIZE-1);
|
||||
strlcpy(obj.label, label, sizeof(obj.label));
|
||||
if (auth_id != NULL)
|
||||
obj.auth_id = *auth_id;
|
||||
|
||||
|
@ -151,7 +152,7 @@ static int sc_pkcs15emu_add_cert(sc_pkcs15_card_t *p15card,
|
|||
if (path)
|
||||
info.path = *path;
|
||||
|
||||
strncpy(obj.label, label, SC_PKCS15_MAX_LABEL_SIZE-1);
|
||||
strlcpy(obj.label, label, sizeof(obj.label));
|
||||
obj.flags = obj_flags;
|
||||
|
||||
return sc_pkcs15emu_add_x509_cert(p15card, &obj, &info);
|
||||
|
@ -326,7 +327,7 @@ static int infocamere_1200_init(sc_pkcs15_card_t * p15card)
|
|||
sc_pkcs15_format_id("1", &cert_info.id);
|
||||
cert_info.authority = authority;
|
||||
cert_info.path = path;
|
||||
strncpy(cert_obj.label, authlabel, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, authlabel, sizeof(cert_obj.label));
|
||||
cert_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE;
|
||||
|
||||
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
|
||||
|
@ -384,7 +385,7 @@ static int infocamere_1200_init(sc_pkcs15_card_t * p15card)
|
|||
|
||||
cert_info.authority = authority;
|
||||
cert_info.path = path;
|
||||
strncpy(cert_obj.label, label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, label, sizeof(cert_obj.label));
|
||||
cert_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE;
|
||||
|
||||
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
|
||||
|
@ -419,7 +420,7 @@ static int infocamere_1200_init(sc_pkcs15_card_t * p15card)
|
|||
sc_pkcs15_format_id("3", &cert_info.id);
|
||||
cert_info.authority = authority;
|
||||
cert_info.path = path;
|
||||
strncpy(cert_obj.label, calabel, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, calabel, sizeof(cert_obj.label));
|
||||
cert_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE;
|
||||
|
||||
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
|
||||
|
@ -545,7 +546,7 @@ static int loadCertificate(sc_pkcs15_card_t * p15card, int i,
|
|||
cert_info.path = cpath;
|
||||
cert_info.authority = (i == 2);
|
||||
|
||||
strncpy(cert_obj.label, certLabel, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, certLabel, sizeof(cert_obj.label));
|
||||
cert_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE;
|
||||
|
||||
sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
int sc_pkcs15emu_openpgp_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *);
|
||||
|
||||
|
@ -153,7 +154,7 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
|
|||
sc_format_path("3F00", &pin_info.path);
|
||||
pin_info.tries_left = buffer[4+i];
|
||||
|
||||
strncpy(pin_obj.label, pgp_pin_name[i], SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(pin_obj.label, pgp_pin_name[i], sizeof(pin_obj.label));
|
||||
pin_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
|
||||
|
||||
r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
|
||||
|
@ -185,7 +186,7 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
|
|||
prkey_info.key_reference = i;
|
||||
prkey_info.modulus_length= 1024;
|
||||
|
||||
strncpy(prkey_obj.label, pgp_key_name[i], SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(prkey_obj.label, pgp_key_name[i], sizeof(prkey_obj.label));
|
||||
prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE | SC_PKCS15_CO_FLAG_MODIFIABLE;
|
||||
prkey_obj.auth_id.len = 1;
|
||||
prkey_obj.auth_id.value[0] = prkey_pin[i];
|
||||
|
@ -216,7 +217,7 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
|
|||
pubkey_info.usage = pubkey_usage[i];
|
||||
sc_format_path(pgp_pubkey_path[i], &pubkey_info.path);
|
||||
|
||||
strncpy(pubkey_obj.label, pgp_key_name[i], SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(pubkey_obj.label, pgp_key_name[i], sizeof(pubkey_obj.label));
|
||||
pubkey_obj.auth_id.len = 1;
|
||||
pubkey_obj.auth_id.value[0] = 3;
|
||||
pubkey_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <openssl/bio.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/pem.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
#define MANU_ID "piv_II "
|
||||
|
||||
|
@ -246,12 +247,12 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
|
|||
memset(&obj_obj, 0, sizeof(obj_obj));
|
||||
sc_pkcs15_format_id(objects[i].id, &obj_info.id);
|
||||
sc_format_path(objects[i].path, &obj_info.path);
|
||||
strncpy(obj_info.app_label, objects[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(obj_info.app_label, objects[i].label, sizeof(obj_info.app_label));
|
||||
r = sc_format_oid(&obj_info.app_oid, objects[i].aoid);
|
||||
if (r != SC_SUCCESS)
|
||||
return r;
|
||||
|
||||
strncpy(obj_obj.label, objects[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(obj_obj.label, objects[i].label, sizeof(obj_obj.label));
|
||||
obj_obj.flags = objects[i].obj_flags;
|
||||
|
||||
r = sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_DATA_OBJECT,
|
||||
|
@ -275,7 +276,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
|
|||
cert_info.authority = certs[i].authority;
|
||||
sc_format_path(certs[i].path, &cert_info.path);
|
||||
|
||||
strncpy(cert_obj.label, certs[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, certs[i].label, sizeof(cert_obj.label));
|
||||
cert_obj.flags = certs[i].obj_flags;
|
||||
|
||||
/* Cards based on NIST 800-73 may enforce pin protected certs */
|
||||
|
@ -310,7 +311,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
|
|||
sc_format_path(pins[i].path, &pin_info.path);
|
||||
pin_info.tries_left = -1;
|
||||
|
||||
strncpy(pin_obj.label, pins[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(pin_obj.label, pins[i].label, sizeof(pin_obj.label));
|
||||
pin_obj.flags = pins[i].obj_flags;
|
||||
|
||||
r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
|
||||
|
@ -346,7 +347,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
|
|||
*/
|
||||
sc_format_path(pubkeys[i].path, &pubkey_info.path);
|
||||
|
||||
strncpy(pubkey_obj.label, pubkeys[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(pubkey_obj.label, pubkeys[i].label, sizeof(pubkey_obj.label));
|
||||
|
||||
pubkey_obj.flags = pubkeys[i].obj_flags;
|
||||
|
||||
|
@ -380,7 +381,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
|
|||
*/
|
||||
sc_format_path(prkeys[i].path, &prkey_info.path);
|
||||
|
||||
strncpy(prkey_obj.label, prkeys[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(prkey_obj.label, prkeys[i].label, sizeof(prkey_obj.label));
|
||||
|
||||
prkey_obj.flags = prkeys[i].obj_flags;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
int sc_pkcs15emu_postecert_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *);
|
||||
|
||||
|
@ -85,7 +86,7 @@ static int sc_pkcs15emu_add_pin(sc_pkcs15_card_t *p15card,
|
|||
if (type == SC_PKCS15_PIN_TYPE_BCD)
|
||||
info.stored_length /= 2;
|
||||
|
||||
strncpy(obj.label, label, SC_PKCS15_MAX_LABEL_SIZE-1);
|
||||
strlcpy(obj.label, label, sizeof(obj.label));
|
||||
obj.flags = obj_flags;
|
||||
|
||||
return sc_pkcs15emu_add_pin_obj(p15card, &obj, &info);
|
||||
|
@ -118,7 +119,7 @@ static int sc_pkcs15emu_add_prkey(sc_pkcs15_card_t *p15card,
|
|||
info.path = *path;
|
||||
|
||||
obj.flags = obj_flags;
|
||||
strncpy(obj.label, label, SC_PKCS15_MAX_LABEL_SIZE-1);
|
||||
strlcpy(obj.label, label, sizeof(obj.label));
|
||||
if (auth_id != NULL)
|
||||
obj.auth_id = *auth_id;
|
||||
|
||||
|
@ -141,7 +142,7 @@ static int sc_pkcs15emu_add_cert(sc_pkcs15_card_t *p15card,
|
|||
if (path)
|
||||
info.path = *path;
|
||||
|
||||
strncpy(obj.label, label, SC_PKCS15_MAX_LABEL_SIZE-1);
|
||||
strlcpy(obj.label, label, sizeof(obj.label));
|
||||
obj.flags = obj_flags;
|
||||
|
||||
return sc_pkcs15emu_add_x509_cert(p15card, &obj, &info);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
#define MANU_ID "Giesecke & Devrient GmbH"
|
||||
#define STARCERT "StarCertV2201"
|
||||
|
@ -194,7 +195,7 @@ static int sc_pkcs15emu_starcert_init(sc_pkcs15_card_t *p15card)
|
|||
/* skip errors */
|
||||
continue;
|
||||
|
||||
strncpy(cert_obj.label, certs[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, certs[i].label, sizeof(cert_obj.label));
|
||||
cert_obj.flags = certs[i].obj_flags;
|
||||
|
||||
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
|
||||
|
@ -220,7 +221,7 @@ static int sc_pkcs15emu_starcert_init(sc_pkcs15_card_t *p15card)
|
|||
sc_format_path(pins[i].path, &pin_info.path);
|
||||
pin_info.tries_left = -1;
|
||||
|
||||
strncpy(pin_obj.label, pins[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(pin_obj.label, pins[i].label, sizeof(pin_obj.label));
|
||||
pin_obj.flags = pins[i].obj_flags;
|
||||
|
||||
r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
|
||||
|
@ -242,7 +243,7 @@ static int sc_pkcs15emu_starcert_init(sc_pkcs15_card_t *p15card)
|
|||
prkey_info.modulus_length= prkeys[i].modulus_len;
|
||||
sc_format_path(prkeys[i].path, &prkey_info.path);
|
||||
|
||||
strncpy(prkey_obj.label, prkeys[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(prkey_obj.label, prkeys[i].label, sizeof(prkey_obj.label));
|
||||
prkey_obj.flags = prkeys[i].obj_flags;
|
||||
if (prkeys[i].auth_id)
|
||||
sc_pkcs15_format_id(prkeys[i].auth_id, &prkey_obj.auth_id);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
static void
|
||||
set_string(char **strp, const char *value)
|
||||
|
@ -196,7 +197,7 @@ int sc_pkcs15emu_tcos_init_ex(sc_pkcs15_card_t *p15card, sc_pkcs15emu_opt_t *opt
|
|||
cert_info.path = path;
|
||||
|
||||
memset(&cert_obj, 0, sizeof(cert_obj));
|
||||
strncpy(cert_obj.label, certlist[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(cert_obj.label, certlist[i].label, sizeof(cert_obj.label));
|
||||
cert_obj.flags = certlist[i].writable ? SC_PKCS15_CO_FLAG_MODIFIABLE : 0;
|
||||
|
||||
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
|
||||
|
@ -240,7 +241,7 @@ int sc_pkcs15emu_tcos_init_ex(sc_pkcs15_card_t *p15card, sc_pkcs15emu_opt_t *opt
|
|||
sc_format_path(keylist[i].path, &prkey_info.path);
|
||||
|
||||
memset(&prkey_obj, 0, sizeof(prkey_obj));
|
||||
strncpy(prkey_obj.label, keylist[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(prkey_obj.label, keylist[i].label, sizeof(prkey_obj.label));
|
||||
prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
|
||||
prkey_obj.auth_id.len = 1;
|
||||
prkey_obj.auth_id.value[0] = keylist[i].auth_id;
|
||||
|
@ -280,7 +281,7 @@ int sc_pkcs15emu_tcos_init_ex(sc_pkcs15_card_t *p15card, sc_pkcs15emu_opt_t *opt
|
|||
sc_format_path(pinlist[i].path, &pin_info.path);
|
||||
|
||||
memset(&pin_obj, 0, sizeof(pin_obj));
|
||||
strncpy(pin_obj.label, pinlist[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
|
||||
strlcpy(pin_obj.label, pinlist[i].label, sizeof(pin_obj.label));
|
||||
pin_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
|
||||
pin_obj.auth_id.len = pinlist[i].auth_id ? 0 : 1;
|
||||
pin_obj.auth_id.value[0] = pinlist[i].auth_id;
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "pkcs15-init.h"
|
||||
#include <opensc/cardctl.h>
|
||||
#include <opensc/log.h>
|
||||
#include "strlcpy.h"
|
||||
|
||||
#define OPENSC_INFO_FILEPATH "3F0050154946"
|
||||
#define OPENSC_INFO_FILEID 0x4946
|
||||
|
@ -197,8 +198,7 @@ get_profile_from_config(sc_card_t *card, char *buffer, size_t size)
|
|||
|
||||
tmp = scconf_get_str(blk, "profile", NULL);
|
||||
if (tmp != NULL) {
|
||||
strncpy(buffer, tmp, size);
|
||||
buffer[size-1] = '\0';
|
||||
strlcpy(buffer, tmp, size);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -340,8 +340,7 @@ sc_pkcs15init_bind(sc_card_t *card, const char *name,
|
|||
if (!get_profile_from_config(card, card_profile, sizeof(card_profile)))
|
||||
strcpy(card_profile, driver);
|
||||
if (profile_option != NULL) {
|
||||
strncpy(card_profile, profile_option, sizeof(card_profile));
|
||||
card_profile[sizeof(card_profile) - 1] = '\0';
|
||||
strlcpy(card_profile, profile_option, sizeof(card_profile));
|
||||
}
|
||||
|
||||
if ((r = sc_profile_load(profile, profile->name)) < 0
|
||||
|
@ -1224,7 +1223,7 @@ sc_pkcs15init_init_prkdf(sc_pkcs15_card_t *p15card,
|
|||
free(key_info); key_info = NULL;
|
||||
free(object); object = *res_obj;
|
||||
|
||||
strncpy(object->label, label, sizeof(object->label));
|
||||
strlcpy(object->label, label, sizeof(object->label));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1620,7 +1619,7 @@ sc_pkcs15init_store_public_key(struct sc_pkcs15_card *p15card,
|
|||
sc_pkcs15_free_object(object);
|
||||
object = *res_obj;
|
||||
|
||||
strncpy(object->label, label, sizeof(object->label));
|
||||
strlcpy(object->label, label, sizeof(object->label));
|
||||
} else {
|
||||
key_info->id = keyargs->id;
|
||||
*res_obj = object;
|
||||
|
@ -1810,8 +1809,8 @@ sc_pkcs15init_store_data_object(struct sc_pkcs15_card *p15card,
|
|||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
data_object_info = (sc_pkcs15_data_info_t *) object->data;
|
||||
if (label != NULL) {
|
||||
strncpy(data_object_info->app_label, label,
|
||||
sizeof(data_object_info->app_label) - 1);
|
||||
strlcpy(data_object_info->app_label, label,
|
||||
sizeof(data_object_info->app_label));
|
||||
}
|
||||
data_object_info->app_oid = args->app_oid;
|
||||
|
||||
|
@ -2684,7 +2683,7 @@ sc_pkcs15init_new_object(int type, const char *label, sc_pkcs15_id_t *auth_id, v
|
|||
}
|
||||
|
||||
if (label)
|
||||
strncpy(object->label, label, sizeof(object->label)-1);
|
||||
strlcpy(object->label, label, sizeof(object->label));
|
||||
if (auth_id)
|
||||
object->auth_id = *auth_id;
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <opensc/log.h>
|
||||
#include "pkcs15-init.h"
|
||||
#include "profile.h"
|
||||
#include "strlcpy.h"
|
||||
|
||||
#define DEF_PRKEY_RSA_ACCESS 0x1D
|
||||
#define DEF_PRKEY_DSA_ACCESS 0x12
|
||||
|
@ -1182,7 +1183,7 @@ do_acl(struct state *cur, int argc, char **argv)
|
|||
while (argc--) {
|
||||
unsigned int op, method, id;
|
||||
|
||||
strncpy(oper, *argv++, sizeof(oper)-1);
|
||||
strlcpy(oper, *argv++, sizeof(oper));
|
||||
if ((what = strchr(oper, '=')) == NULL)
|
||||
goto bad;
|
||||
*what++ = '\0';
|
||||
|
@ -1753,8 +1754,7 @@ get_authid(struct state *cur, const char *value,
|
|||
}
|
||||
|
||||
n = strcspn(value, "0123456789");
|
||||
strncpy(temp, value, n);
|
||||
temp[n] = '\0';
|
||||
strlcpy(temp, value, n);
|
||||
|
||||
if (map_str2int(cur, temp, type, aclNames))
|
||||
return 1;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <errno.h>
|
||||
#include "scconf.h"
|
||||
#include "internal.h"
|
||||
#include "strlcpy.h"
|
||||
|
||||
#define STATE_NAME 0x01
|
||||
#define STATE_VALUE 0x02
|
||||
|
@ -386,7 +387,7 @@ int scconf_parse(scconf_context * config)
|
|||
config->filename, strerror(errno));
|
||||
r = -1;
|
||||
} else if (p.error) {
|
||||
strncpy(buffer, p.emesg, sizeof(buffer)-1);
|
||||
strlcpy(buffer, p.emesg, sizeof(buffer));
|
||||
r = 0;
|
||||
} else {
|
||||
r = 1;
|
||||
|
@ -413,7 +414,7 @@ int scconf_parse_string(scconf_context * config, const char *string)
|
|||
"Failed to parse configuration string");
|
||||
r = -1;
|
||||
} else if (p.error) {
|
||||
strncpy(buffer, p.emesg, sizeof(buffer)-1);
|
||||
strlcpy(buffer, p.emesg, sizeof(buffer));
|
||||
r = 0;
|
||||
} else {
|
||||
r = 1;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <openssl/err.h>
|
||||
#include <opensc/pkcs15.h>
|
||||
#include "util.h"
|
||||
#include "strlcpy.h"
|
||||
|
||||
const char *app_name = "cryptoflex-tool";
|
||||
|
||||
|
@ -104,8 +105,7 @@ static char *getpin(const char *prompt)
|
|||
return NULL;
|
||||
}
|
||||
memset(buf, 0, 8);
|
||||
strncpy(buf, pass, 8);
|
||||
memset(pass, 0, strlen(pass));
|
||||
strlcpy(buf, pass, 8);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include <opensc/ui.h>
|
||||
#include <opensc/cards.h>
|
||||
#include "util.h"
|
||||
#include "strlcpy.h"
|
||||
|
||||
|
||||
#undef GET_KEY_ECHO_OFF
|
||||
|
@ -1299,8 +1300,7 @@ do_change_attributes(struct sc_profile *profile, unsigned int opt_type)
|
|||
}
|
||||
|
||||
if (opt_label != NULL) {
|
||||
strncpy(obj->label, opt_label, SC_PKCS15_MAX_LABEL_SIZE);
|
||||
obj->label[SC_PKCS15_MAX_LABEL_SIZE - 1] = '\0';
|
||||
strlcpy(obj->label, opt_label, sizeof(obj->label));
|
||||
}
|
||||
|
||||
set_userpin_ref();
|
||||
|
|
Loading…
Reference in New Issue