Allow CryptoExceptions to be fatal

This commit is contained in:
Keegan McAllister
2012-03-26 21:02:23 -04:00
parent 519d1ee282
commit ba6387f36c
3 changed files with 15 additions and 5 deletions
+3 -1
View File
@@ -32,7 +32,9 @@ namespace Crypto {
class CryptoException { class CryptoException {
public: public:
string text; string text;
CryptoException( string s_text ) : text( s_text ) {}; bool fatal;
CryptoException( string s_text, bool s_fatal = false )
: text( s_text ), fatal( s_fatal ) {};
}; };
class Base64Key { class Base64Key {
+5 -1
View File
@@ -592,7 +592,11 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
fprintf( stderr, "%s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); fprintf( stderr, "%s: %s\n", e.function.c_str(), strerror( e.the_errno ) );
spin(); spin();
} catch ( Crypto::CryptoException e ) { } catch ( Crypto::CryptoException e ) {
fprintf( stderr, "Crypto exception: %s\n", e.text.c_str() ); if ( e.fatal ) {
throw;
} else {
fprintf( stderr, "Crypto exception: %s\n", e.text.c_str() );
}
} }
} }
} }
+7 -3
View File
@@ -398,9 +398,13 @@ void STMClient::main( void )
req.tv_nsec = 200000000; /* 0.2 sec */ req.tv_nsec = 200000000; /* 0.2 sec */
nanosleep( &req, NULL ); nanosleep( &req, NULL );
} catch ( Crypto::CryptoException e ) { } catch ( Crypto::CryptoException e ) {
wchar_t tmp[ 128 ]; if ( e.fatal ) {
swprintf( tmp, 128, L"Crypto exception: %s", e.text.c_str() ); throw;
overlays.get_notification_engine().set_notification_string( wstring( tmp ) ); } else {
wchar_t tmp[ 128 ];
swprintf( tmp, 128, L"Crypto exception: %s", e.text.c_str() );
overlays.get_notification_engine().set_notification_string( wstring( tmp ) );
}
} }
} }
} }