#include "TrustSettingsSchema.h"
#include <Security/SecTrustPriv.h>
#include "utilities/array_size.h"
+#include "utilities/SecCFWrappers.h"
#include <AssertMacros.h>
#include <syslog.h>
SecKeychainAttributeList* &attrList
)
{
+ // make storage to extract the dictionary items
+ CFIndex itemsInDictionary = CFDictionaryGetCount(dictionaryRef);
+ if (itemsInDictionary > 10000) {
+ return errSecParam;
+ }
+
// get the keychain attributes array from the data item
// here's the problem. On the one hand, we have a dictionary that is purported to contain
// attributes for our type. On the other hand, the dictionary may contain items we don't support,
// setup the return
attrList = (SecKeychainAttributeList*) calloc(1, sizeof(SecKeychainAttributeList));
- // make storage to extract the dictionary items
- CFIndex itemsInDictionary = CFDictionaryGetCount(dictionaryRef);
std::vector<CFTypeRef> keys(itemsInDictionary);
std::vector<CFTypeRef> values(itemsInDictionary);
if(count == 0) {
attrList->attr = NULL;
} else {
- attrList->attr = (SecKeychainAttribute*) malloc(sizeof(SecKeychainAttribute) * count);
+ attrList->attr = (SecKeychainAttribute*) calloc(count, sizeof(SecKeychainAttribute));
// fill out the array
int resultPointer = 0;
// make attribute list for new item (the data is still owned by attrList)
newAttrList.count = attrList->count;
- newAttrList.attr = (SecKeychainAttribute *) malloc(sizeof(SecKeychainAttribute) * attrList->count);
+ newAttrList.attr = (SecKeychainAttribute *) calloc(attrList->count, sizeof(SecKeychainAttribute));
int i, newCount;
for (i=0, newCount=0; i < attrList->count; i++) {
if (attrList->attr[i].length > 0) {
CFTypeRef v;
Item item = Item(item_class, &attrs, 0, "");
- v = CFDictionaryGetValue(refAttributes, kSecValuePersistentRef);
+ v = CFCast(CFData, CFDictionaryGetValue(refAttributes, kSecValuePersistentRef));
if (v) {
item->setPersistentRef((CFDataRef)v);
}