Check-in [90faf75892]
Overview
Comment:Protected access to cackey_slots with mutex
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dodcerts-on-seperate-slot
Files: files | file ages | folders
SHA1:90faf75892ba3296c49d1615a07245e890cc7dbb
User & Date: rkeene on 2012-07-21 06:19:19
Other Links: manifest | tags
Context
2012-07-21
06:50
Updated to allow the user to specify (via environment variables) whether or not to include the DoD certificates on the hardware slot tokens check-in: b957a3fa2e user: rkeene tags: dodcerts-on-seperate-slot
06:19
Protected access to cackey_slots with mutex check-in: 90faf75892 user: rkeene tags: dodcerts-on-seperate-slot
06:09
Added support for treating the DoD certs as a seperate slot check-in: b6b2190360 user: rkeene tags: dodcerts-on-seperate-slot
Changes

Modified cackey.c from [42750d148e] to [8e07ff4bd1].

  3828   3828   	if (count < slot_count) {
  3829   3829   		CACKEY_DEBUG_PRINTF("Error. User allocated %lu entries, but we have %lu entries.", count, slot_count);
  3830   3830   
  3831   3831   		CACKEY_DEBUG_PRINTF("Returning CKR_BUFFER_TOO_SMALL");
  3832   3832   
  3833   3833   		return(CKR_BUFFER_TOO_SMALL);	
  3834   3834   	}
         3835  +
         3836  +	mutex_retval = cackey_mutex_lock(cackey_biglock);
         3837  +	if (mutex_retval != 0) {
         3838  +		CACKEY_DEBUG_PRINTF("Error.  Locking failed.");
         3839  +
         3840  +		return(CKR_GENERAL_ERROR);
         3841  +	}
  3835   3842   
  3836   3843   	slot_idx = 0;
  3837   3844   	for (currslot = 0; (currslot < (sizeof(cackey_slots) / sizeof(cackey_slots[0]))); currslot++) {
  3838   3845   		if (!cackey_slots[currslot].active) {
  3839   3846   			continue;
  3840   3847   		}
  3841   3848   
  3842   3849   		if (slot_idx >= count) {
  3843         -			CACKEY_DEBUG_PRINTF("Error. User allocated %lu entries, but we just tried to write to the %lu index.", count, slot_idx);
         3850  +			CACKEY_DEBUG_PRINTF("Error. User allocated %lu entries, but we just tried to write to the %lu index -- ignoring", count, slot_idx);
  3844   3851   
  3845         -			CACKEY_DEBUG_PRINTF("Returning CKR_BUFFER_TOO_SMALL");
  3846         -
  3847         -			return(CKR_BUFFER_TOO_SMALL);	
         3852  +			continue;
  3848   3853   		}
  3849   3854   
  3850   3855   		pSlotList[slot_idx] = currslot;
  3851   3856   		slot_idx++;
  3852   3857   	}
         3858  +
         3859  +	mutex_retval = cackey_mutex_unlock(cackey_biglock);
         3860  +	if (mutex_retval != 0) {
         3861  +		CACKEY_DEBUG_PRINTF("Error.  Unlocking failed.");
         3862  +
         3863  +		return(CKR_GENERAL_ERROR);
         3864  +	}
  3853   3865   
  3854   3866   	*pulCount = slot_count;
  3855   3867   
  3856   3868   	CACKEY_DEBUG_PRINTF("Returning CKR_OK (%i).  Found %lu readers.", CKR_OK, (unsigned long) slot_count);
  3857   3869   
  3858   3870   	return(CKR_OK);
  3859   3871