]> git.saurik.com Git - apple/security.git/blobdiff - cdsa/cdsa_utilities/MetaRecord.cpp
Security-177.tar.gz
[apple/security.git] / cdsa / cdsa_utilities / MetaRecord.cpp
index cc84191d5910059578ddb30b1ad19799c66314b6..8a67d4d615d07524dcf466ba4d87a0f32a0e5246 100644 (file)
@@ -21,6 +21,7 @@
 //
 
 #include "MetaRecord.h"
 //
 
 #include "MetaRecord.h"
+#include <Security/trackingallocator.h>
 
 MetaRecord::MetaRecord(CSSM_DB_RECORDTYPE inRecordType) :
     mRecordType(inRecordType)
 
 MetaRecord::MetaRecord(CSSM_DB_RECORDTYPE inRecordType) :
     mRecordType(inRecordType)
@@ -45,12 +46,6 @@ MetaRecord::MetaRecord(CSSM_DB_RECORDTYPE inRelationID,
                                           const CSSM_DB_SCHEMA_ATTRIBUTE_INFO *inAttributeInfo) :
     mRecordType(inRelationID)
 {
                                           const CSSM_DB_SCHEMA_ATTRIBUTE_INFO *inAttributeInfo) :
     mRecordType(inRelationID)
 {
-       // XXX Is there any particular reason not to allow this?
-#if 0
-       if (inNumberOfAttributes == 0 || inAttributeInfo == NULL)
-               CssmError::throwMe(CSSMERR_DL_UNSUPPORTED_NUM_ATTRIBUTES);
-#endif
-
        try {
                for (uint32 anIndex = 0; anIndex < inNumberOfAttributes; anIndex++)
                {
        try {
                for (uint32 anIndex = 0; anIndex < inNumberOfAttributes; anIndex++)
                {
@@ -83,12 +78,6 @@ MetaRecord::~MetaRecord()
 void
 MetaRecord::setRecordAttributeInfo(const CSSM_DB_RECORD_ATTRIBUTE_INFO &inInfo)
 {
 void
 MetaRecord::setRecordAttributeInfo(const CSSM_DB_RECORD_ATTRIBUTE_INFO &inInfo)
 {
-       // XXX Is there any particular reason not to allow this?
-#if 0
-    if (inInfo.NumberOfAttributes == 0 || inInfo.AttributeInfo == NULL)
-        CssmError::throwMe(CSSMERR_DL_UNSUPPORTED_NUM_ATTRIBUTES);
-#endif
-
     for (uint32 anIndex = 0; anIndex < inInfo.NumberOfAttributes; anIndex++)
     {
         switch (inInfo.AttributeInfo[anIndex].AttributeNameFormat)
     for (uint32 anIndex = 0; anIndex < inInfo.NumberOfAttributes; anIndex++)
     {
         switch (inInfo.AttributeInfo[anIndex].AttributeNameFormat)
@@ -299,6 +288,10 @@ MetaRecord::unpackRecord(const ReadSection &inReadSection,
 
 // Return the index (0 though NumAttributes - 1) of the attribute
 // represented by inAttributeInfo
 
 // Return the index (0 though NumAttributes - 1) of the attribute
 // represented by inAttributeInfo
+
+#ifndef        NDEBUG
+#define LOG_NAME_AS_STRING_FAIL                
+#endif
 uint32
 MetaRecord::attributeIndex(const CSSM_DB_ATTRIBUTE_INFO &inAttributeInfo) const
 {
 uint32
 MetaRecord::attributeIndex(const CSSM_DB_ATTRIBUTE_INFO &inAttributeInfo) const
 {
@@ -308,9 +301,20 @@ MetaRecord::attributeIndex(const CSSM_DB_ATTRIBUTE_INFO &inAttributeInfo) const
            case CSSM_DB_ATTRIBUTE_NAME_AS_STRING:
                {
                        string aName(inAttributeInfo.Label.AttributeName);
            case CSSM_DB_ATTRIBUTE_NAME_AS_STRING:
                {
                        string aName(inAttributeInfo.Label.AttributeName);
+                       assert(aName.size() < 500);             // MDS leak debug
                        NameStringMap::const_iterator it = mNameStringMap.find(aName);
                        NameStringMap::const_iterator it = mNameStringMap.find(aName);
-                       if (it == mNameStringMap.end())
+                       if (it == mNameStringMap.end()) {
+                               #ifdef  LOG_NAME_AS_STRING_FAIL
+                               printf("NAME_AS_STRING failure; attrName %s\n", 
+                                       inAttributeInfo.Label.AttributeName);
+                               for(it = mNameStringMap.begin();
+                                   it != mNameStringMap.end();
+                                       it++) {
+                                               printf("name %s val %lu\n", it->first.c_str(), it->second);
+                               }
+                               #endif
                                CssmError::throwMe(CSSMERR_DL_INVALID_FIELD_NAME);
                                CssmError::throwMe(CSSMERR_DL_INVALID_FIELD_NAME);
+                       }
                        anIndex = it->second;
                        break;
                }
                        anIndex = it->second;
                        break;
                }