X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/fa7225c82381bac4432a6edf16f53b5370238d85..refs/heads/master:/OSX/libsecurity_filedb/lib/AppleDatabase.cpp diff --git a/OSX/libsecurity_filedb/lib/AppleDatabase.cpp b/OSX/libsecurity_filedb/lib/AppleDatabase.cpp index 6155d798..7f37d472 100644 --- a/OSX/libsecurity_filedb/lib/AppleDatabase.cpp +++ b/OSX/libsecurity_filedb/lib/AppleDatabase.cpp @@ -110,7 +110,7 @@ Table::readIndexSection() uint32 indexOffset = mTableSection.at(indexSectionOffset + (i + 2) * AtomSize); ReadSection indexSection(mTableSection.subsection(indexOffset)); - auto_ptr index(new DbConstIndex(*this, indexSection)); + unique_ptr index(new DbConstIndex(*this, indexSection)); mIndexMap.insert(ConstIndexMap::value_type(index->indexId(), index.get())); index.release(); } @@ -289,7 +289,7 @@ ModifiedTable::insertRecord(uint32 inVersionId, { modifyTable(); - auto_ptr aWriteSection(new WriteSection()); + unique_ptr aWriteSection(new WriteSection()); getMetaRecord().packRecord(*aWriteSection, inAttributes, inData); uint32 aRecordNumber = nextRecordNumber(); @@ -341,7 +341,7 @@ ModifiedTable::updateRecord(const RecordId &inRecordId, #endif // Update the actual packed record. - auto_ptr aDbRecord(new WriteSection()); + unique_ptr aDbRecord(new WriteSection()); getMetaRecord().updateRecord(anOldDbRecord, *aDbRecord, CssmDbRecordAttributeData::overlay(inAttributes), inData, inModifyMode); @@ -507,7 +507,7 @@ ModifiedTable::createMutableIndexes() Table::ConstIndexMap::const_iterator it; for (it = mTable->mIndexMap.begin(); it != mTable->mIndexMap.end(); it++) { - auto_ptr mutableIndex(new DbMutableIndex(*it->second)); + unique_ptr mutableIndex(new DbMutableIndex(*it->second)); mIndexMap.insert(MutableIndexMap::value_type(it->first, mutableIndex.get())); mutableIndex.release(); } @@ -522,7 +522,7 @@ ModifiedTable::findIndex(uint32 indexId, const MetaRecord &metaRecord, bool isUn if (it == mIndexMap.end()) { // create the new index - auto_ptr index(new DbMutableIndex(metaRecord, indexId, isUniqueIndex)); + unique_ptr index(new DbMutableIndex(metaRecord, indexId, isUniqueIndex)); it = mIndexMap.insert(MutableIndexMap::value_type(indexId, index.get())).first; index.release(); } @@ -932,7 +932,7 @@ DbVersion::open() // XXX Set the size boundary on aTableSection. const ReadSection aTableSection = aSchemaSection.subsection(aTableOffset); - auto_ptr aTable(new Table(aTableSection)); + unique_ptr
aTable(new Table(aTableSection)); Table::Id aTableId = aTable->getMetaRecord().dataRecordType(); mTableMap.insert(TableMap::value_type(aTableId, aTable.get())); aTable.release(); @@ -1048,7 +1048,7 @@ DbVersion::open() uint32 anAttributeId = aRecordData[1]; uint32 anAttributeNameFormat = aRecordData[2]; uint32 anAttributeFormat = aRecordData[5]; - auto_ptr aName; + unique_ptr aName; const CssmData *aNameID = NULL; if (aRecordData[3].size() == 1) @@ -1056,8 +1056,8 @@ DbVersion::open() if (aRecordData[3].format() != CSSM_DB_ATTRIBUTE_FORMAT_STRING) CssmError::throwMe(CSSMERR_DL_DATABASE_CORRUPT); - auto_ptr aName2(new string(static_cast(aRecordData[3]))); - aName = aName2; + unique_ptr aName2(new string(static_cast(aRecordData[3]))); + aName = std::move(aName2); } if (aRecordData[4].size() == 1) @@ -1300,7 +1300,7 @@ IndexCursor::IndexCursor(DbQueryKey *queryKey, const DbVersion &inDbVersion, IndexCursor::~IndexCursor() { - // the query key will be deleted automatically, since it's an auto_ptr + // the query key will be deleted automatically, since it's an unique_ptr } bool @@ -1554,7 +1554,7 @@ DbModifier::modifyDatabase() mDbVersion->mTableMap.end(); for (; anIt != anEnd; ++anIt) { - auto_ptr aTable(new ModifiedTable(anIt->second)); + unique_ptr aTable(new ModifiedTable(anIt->second)); mModifiedTableMap.insert(ModifiedTableMap::value_type(anIt->first, aTable.get())); aTable.release(); @@ -1601,8 +1601,8 @@ DbModifier::updateRecord(Table::Id inTableId, const RecordId &inRecordId, ModifiedTable * DbModifier::createTable(MetaRecord *inMetaRecord) { - auto_ptr aMetaRecord(inMetaRecord); - auto_ptr aModifiedTable(new ModifiedTable(inMetaRecord)); + unique_ptr aMetaRecord(inMetaRecord); + unique_ptr aModifiedTable(new ModifiedTable(inMetaRecord)); // Now that aModifiedTable is fully constructed it owns inMetaRecord aMetaRecord.release(); @@ -1687,7 +1687,7 @@ DbModifier::commit() return; try { - secnotice("integrity", "committing to %s", mAtomicFile.path().c_str()); + secinfo("integrity", "committing to %s", mAtomicFile.path().c_str()); WriteSection aHeaderSection(Allocator::standard(), size_t(HeaderSize)); // Set aHeaderSection to the correct size. @@ -1744,7 +1744,7 @@ DbModifier::commit() } void -DbModifier::rollback() throw() +DbModifier::rollback() _NOEXCEPT { // This will destroy the AtomicTempFile if we have one causing it to rollback. mAtomicTempFile = NULL; @@ -2294,40 +2294,6 @@ AppleDatabase::dataDelete(DbContext &inDbContext, { try { - // syslog if it's the .Mac password - CSSM_DB_RECORD_ATTRIBUTE_DATA attrData; - // we have to do this in two phases -- the first to get the record type, and the second to actually read the attributes. Otherwise, we might get - // an exception. - memset(&attrData, 0, sizeof(attrData)); - dataGetFromUniqueRecordId(inDbContext, inUniqueRecord, &attrData, NULL); - - if (attrData.DataRecordType == CSSM_DL_DB_RECORD_GENERIC_PASSWORD) - { - CSSM_DB_ATTRIBUTE_DATA attributes; - - // setup some attributes and see if we are indeed the .Mac password - attributes.Info.AttributeNameFormat = CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER; - attributes.Info.Label.AttributeID = 'svce'; - attributes.Info.AttributeFormat = 0; - attributes.NumberOfValues = 1; - attributes.Value = NULL; - - attrData.NumberOfAttributes = 1; - attrData.AttributeData = &attributes; - - dataGetFromUniqueRecordId(inDbContext, inUniqueRecord, &attrData, NULL); - - // now check the results - std::string dataString((const char*) attrData.AttributeData[0].Value[0].Data, attrData.AttributeData[0].Value[0].Length); - if (dataString == "iTools") - { - syslog(LOG_WARNING, "Warning: Removed .Me password"); - } - - free(attrData.AttributeData[0].Value[0].Data); - free(attrData.AttributeData[0].Value); - } - StLock _(mWriteLock); Table::Id aTableId; const RecordId aRecordId(parseUniqueRecord(inUniqueRecord, aTableId)); @@ -2401,7 +2367,7 @@ AppleDatabase::dataGetFirst(DbContext &inDbContext, { // XXX: register Cursor with DbContext and have DbContext call // dataAbortQuery for all outstanding Query objects on close. - auto_ptr aCursor(mDbModifier.createCursor(inQuery)); + unique_ptr aCursor(mDbModifier.createCursor(inQuery)); Table::Id aTableId; RecordId aRecordId; @@ -2421,7 +2387,7 @@ AppleDatabase::dataGetNext(DbContext &inDbContext, CssmData *inoutData, CSSM_DB_UNIQUE_RECORD_PTR &outUniqueRecord) { - auto_ptr aCursor(&HandleObject::find(inResultsHandle, CSSMERR_DL_INVALID_RESULTS_HANDLE)); + unique_ptr aCursor(&HandleObject::find(inResultsHandle, CSSMERR_DL_INVALID_RESULTS_HANDLE)); Table::Id aTableId; RecordId aRecordId; @@ -2578,7 +2544,6 @@ AppleDatabase::passThrough(DbContext &dbContext, default: CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED); - break; } }