fixed argument checking

This commit is contained in:
Frank Morgner 2019-01-28 09:56:50 +01:00
parent 6fdb29a470
commit c858d4b3d1
3 changed files with 10 additions and 3 deletions

View File

@ -284,8 +284,10 @@ sc_pkcs15_get_extension(struct sc_context *ctx, struct sc_pkcs15_cert *cert,
}
else {
*ext_val_len = MIN(*ext_val_len, val_len);
memcpy(*ext_val, val, *ext_val_len);
free(val);
if (val) {
memcpy(*ext_val, val, *ext_val_len);
free(val);
}
}
if (is_critical)

View File

@ -853,6 +853,11 @@ static int cardos_change_startkey(const char *change_startkey_apdu)
u8 rbuf[256];
int r;
if (!change_startkey_apdu) {
printf("Missing change StartKey, aborting\n");
return 1;
}
if (verbose) {
printf ("Change StartKey APDU:\n");
util_hex_dump_asc(stdout, (unsigned char *)change_startkey_apdu,

View File

@ -262,7 +262,7 @@ static int admin_mode(const char* admin_info)
size_t buflen = 2;
if (strlen(admin_info) == 7 &&
if (admin_info && strlen(admin_info) == 7 &&
(admin_info[0] == 'A' || admin_info[0] == 'M') &&
admin_info[1] == ':' &&
(sc_hex_to_bin(admin_info+2, opts+1, &buflen) == 0) &&