#include <security_filedb/AtomicFile.h>
-#include <security_utilities/devrandom.h>
#include <CommonCrypto/CommonDigest.h>
#include <security_cdsa_utilities/cssmerrors.h>
#include <Security/cssm.h>
+#include <Security/SecRandom.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <copyfile.h>
#include <sandbox.h>
#include <set>
-#include <assert.h>
+#include <security_utilities/simulatecrash_assert.h>
#define kAtomicFileMaxBlockSize INT_MAX
{
if (mFileRef >= 0)
{
- // In release mode, the assert() is compiled out so rv may be unused.
- __unused int rv = AtomicFile::rclose(mFileRef);
+ // In release mode, the assert() is compiled out so rv may be unused.
+ __unused int rv = AtomicFile::rclose(mFileRef);
assert(rv == 0);
secinfo("atomicfile", "%p closed %s", this, mPath.c_str());
}
// Rollback the current create or write (happens automatically if commit() isn't called before the destructor is.
void
-AtomicTempFile::rollback() throw()
+AtomicTempFile::rollback() _NOEXCEPT
{
if (mFileRef >= 0)
{
NetworkFileLocker::unique(mode_t mode)
{
static const int randomPart = 16;
- DevRandomGenerator randomGen;
std::string::size_type dirSize = mDir.size();
std::string fullname(dirSize + randomPart + 2, '\0');
fullname.replace(0, dirSize, mDir);
for (int retries = 0; retries < 10; ++retries)
{
/* Make a random filename. */
- randomGen.random(buf, randomPart);
+ MacOSError::check(SecRandomCopyBytes(kSecRandomDefault, randomPart, buf));
for (int ix = 0; ix < randomPart; ++ix)
{
char ch = buf[ix] & 0x3f;
-void AtomicLockedFile::unlock() throw()
+void AtomicLockedFile::unlock() _NOEXCEPT
{
mFileLocker->unlock();
}