sc-hsm: fixed accessing version info (#1252)

fixes https://github.com/OpenSC/OpenSC/issues/1244
This commit is contained in:
Frank Morgner 2018-02-07 12:00:09 +01:00 committed by GitHub
parent 88175e35d3
commit 36894c87cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -1610,14 +1610,17 @@ static int sc_hsm_init(struct sc_card *card)
sc_path_set(&path, SC_PATH_TYPE_DF_NAME, sc_hsm_aid.value, sc_hsm_aid.len, 0, 0);
if (sc_hsm_select_file_ex(card, &path, 0, &file) == SC_SUCCESS
&& file && file->prop_attr && file->prop_attr_len >= 5) {
&& file && file->prop_attr && file->prop_attr_len >= 2) {
static char card_name[SC_MAX_APDU_BUFFER_SIZE];
u8 type = file->prop_attr[2];
u8 major = file->prop_attr[3];
u8 minor = file->prop_attr[4];
u8 type = 0xFF;
u8 major = file->prop_attr[file->prop_attr_len - 2];
u8 minor = file->prop_attr[file->prop_attr_len - 1];
char p00[] = "SmartCard-HSM Applet for JCOP";
char p01[] = "SmartCard-HSM Demo Applet for JCOP";
char *p = "SmartCard-HSM";
if (file->prop_attr_len >= 3) {
type = file->prop_attr[file->prop_attr_len - 3];
}
switch (type) {
case 0x00:
p = p00;

View File

@ -821,8 +821,10 @@ static int sc_pkcs15emu_sc_hsm_init (sc_pkcs15_card_t * p15card)
p15card->card->version.hw_major = 24; /* JCOP 2.4.1r3 */
p15card->card->version.hw_minor = 13;
p15card->card->version.fw_major = file->prop_attr[file->prop_attr_len - 2];
p15card->card->version.fw_minor = file->prop_attr[file->prop_attr_len - 1];
if (file && file->prop_attr && file->prop_attr_len >= 2) {
p15card->card->version.fw_major = file->prop_attr[file->prop_attr_len - 2];
p15card->card->version.fw_minor = file->prop_attr[file->prop_attr_len - 1];
}
sc_file_free(file);