X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/fa7225c82381bac4432a6edf16f53b5370238d85..650c69f3f74fd8ed7cca83ea430e351a1c2fee04:/OSX/libsecurity_utilities/lib/errors.cpp diff --git a/OSX/libsecurity_utilities/lib/errors.cpp b/OSX/libsecurity_utilities/lib/errors.cpp index 7384c990..e715b11d 100644 --- a/OSX/libsecurity_utilities/lib/errors.cpp +++ b/OSX/libsecurity_utilities/lib/errors.cpp @@ -27,9 +27,12 @@ // #include #include +#include +#include #include #include #include +#include #include #include @@ -121,13 +124,15 @@ UnixError::UnixError() : error(errno) LogBacktrace(); } -UnixError::UnixError(int err) : error(err) +UnixError::UnixError(int err, bool suppresslogging) : error(err) { SECURITY_EXCEPTION_THROW_UNIX(this, err); - snprintf(whatBuffer, whatBufferSize, "UNIX error exception: %d", this->error); - secnotice("security_exception", "%s", what()); - LogBacktrace(); + if(!suppresslogging || secinfoenabled("security_exception")) { + snprintf(whatBuffer, whatBufferSize, "UNIX error exception: %d", this->error); + secnotice("security_exception", "%s", what()); + LogBacktrace(); + } } const char *UnixError::what() const throw () @@ -144,10 +149,12 @@ OSStatus UnixError::osStatus() const int UnixError::unixError() const { return error; } -void UnixError::throwMe(int err) { throw UnixError(err); } +void UnixError::throwMe(int err) { throw UnixError(err, false); } +void UnixError::throwMeNoLogging(int err) { throw UnixError(err, true); } + // @@@ This is a hack for the Network protocol state machine -UnixError UnixError::make(int err) { return UnixError(err); } +UnixError UnixError::make(int err) { return UnixError(err, false); } // @@ -158,8 +165,14 @@ MacOSError::MacOSError(int err) : error(err) SECURITY_EXCEPTION_THROW_OSSTATUS(this, err); snprintf(whatBuffer, whatBufferSize, "MacOS error: %d", this->error); - secnotice("security_exception", "%s", what()); - LogBacktrace(); + switch (err) { + case errSecCSReqFailed: + // This 'error' isn't an actual error and doesn't warrant being logged. + break; + default: + secnotice("security_exception", "%s", what()); + LogBacktrace(); + } } const char *MacOSError::what() const throw () @@ -186,6 +199,12 @@ int MacOSError::unixError() const void MacOSError::throwMe(int error) { throw MacOSError(error); } +void MacOSError::throwMe(int error, char const *message, ...) +{ + // Ignoring the message for now, will do something with it later. + throw MacOSError(error); +} + MacOSError MacOSError::make(int error) { return MacOSError(error); }