Diff

Differences From Artifact [c4124c11f6]:

To Artifact [984e852cb7]:


  3411   3411   	}
  3412   3412   
  3413   3413   	free(identities);
  3414   3414   }
  3415   3415   
  3416   3416   static unsigned long cackey_read_dod_identities(struct cackey_identity *identities, unsigned long num_dod_certs) {
  3417   3417   	unsigned long cert_idx, id_idx = 0;
         3418  +
         3419  +	if (identities == NULL) {
         3420  +		return(num_dod_certs * 3);
         3421  +	}
  3418   3422   
  3419   3423   	for (cert_idx = 0; cert_idx < num_dod_certs; cert_idx++) {
  3420   3424   		identities[id_idx].pcsc_identity = NULL;
  3421   3425   		identities[id_idx].attributes = cackey_get_attributes(CKO_CERTIFICATE, &extra_certs[cert_idx], 0xf000 | cert_idx, &identities[id_idx].attributes_count);
  3422   3426   		id_idx++;
  3423   3427   
  3424   3428   		identities[id_idx].pcsc_identity = NULL;
................................................................................
  3463   3467   	if (getenv("CACKEY_NO_EXTRA_CERTS") != NULL) {
  3464   3468   		num_dod_certs = 0;
  3465   3469   	} else {
  3466   3470   		num_dod_certs = sizeof(extra_certs) / sizeof(extra_certs[0]);
  3467   3471   	}
  3468   3472   
  3469   3473   	if (slot->internal) {
  3470         -		num_ids = num_dod_certs * 3;
         3474  +		num_ids = cackey_read_dod_identities(NULL, num_dod_certs);
  3471   3475   
  3472   3476   		if (num_ids != 0) {
  3473   3477   			identities = malloc(num_ids * sizeof(*identities));
  3474   3478   
  3475   3479   			cackey_read_dod_identities(identities, num_dod_certs);
  3476   3480   		} else {
  3477   3481   			identities = NULL;
................................................................................
  3484   3488   
  3485   3489   	pcsc_identities = cackey_read_certs(slot, NULL, &num_certs);
  3486   3490   	if (pcsc_identities != NULL) {
  3487   3491   		/* Convert number of Certs to number of objects */
  3488   3492   		num_ids = (CKO_PRIVATE_KEY - CKO_CERTIFICATE + 1) * num_certs;
  3489   3493   
  3490   3494   		if (include_extra_certs) {
  3491         -			num_ids += num_dod_certs * 3;
         3495  +			num_ids += cackey_read_dod_identities(NULL, num_dod_certs);
  3492   3496   		}
  3493   3497   
  3494   3498   		identities = malloc(num_ids * sizeof(*identities));
  3495   3499   
  3496   3500   		/* Add certificates, public keys, and private keys from the smartcard */
  3497   3501   		id_idx = 0;
  3498   3502   		for (cert_idx = 0; cert_idx < num_certs; cert_idx++) {