diff --git a/src/frontend/mosh-client.cc b/src/frontend/mosh-client.cc index 2c1709c..fa5114b 100644 --- a/src/frontend/mosh-client.cc +++ b/src/frontend/mosh-client.cc @@ -124,13 +124,13 @@ int main( int argc, char *argv[] ) } client.shutdown(); - } catch ( Network::NetworkException e ) { + } catch ( const Network::NetworkException& e ) { fprintf( stderr, "Network exception: %s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) ); - } catch ( Crypto::CryptoException e ) { + } catch ( const Crypto::CryptoException& e ) { fprintf( stderr, "Crypto exception: %s\r\n", e.text.c_str() ); - } catch ( std::string s ) { + } catch ( const std::string& s ) { fprintf( stderr, "Error: %s\r\n", s.c_str() ); } diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 200535e..6e35eb8 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -277,11 +277,11 @@ int main( int argc, char *argv[] ) try { return run_server( desired_ip, desired_port, command_path, command_argv, colors, verbose, with_motd ); - } catch ( Network::NetworkException e ) { + } catch ( const Network::NetworkException& e ) { fprintf( stderr, "Network exception: %s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); return 1; - } catch ( Crypto::CryptoException e ) { + } catch ( const Crypto::CryptoException& e ) { fprintf( stderr, "Crypto exception: %s\n", e.text.c_str() ); return 1; @@ -436,10 +436,10 @@ int run_server( const char *desired_ip, const char *desired_port, try { serve( master, terminal, *network ); - } catch ( Network::NetworkException e ) { + } catch ( const Network::NetworkException& e ) { fprintf( stderr, "Network exception: %s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); - } catch ( Crypto::CryptoException e ) { + } catch ( const Crypto::CryptoException& e ) { fprintf( stderr, "Crypto exception: %s\n", e.text.c_str() ); } @@ -689,10 +689,10 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network } network.tick(); - } catch ( Network::NetworkException e ) { + } catch ( const Network::NetworkException& e ) { fprintf( stderr, "%s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); spin(); - } catch ( Crypto::CryptoException e ) { + } catch ( const Crypto::CryptoException& e ) { if ( e.fatal ) { throw; } else { diff --git a/src/network/network.cc b/src/network/network.cc index 7dfe225..095b188 100644 --- a/src/network/network.cc +++ b/src/network/network.cc @@ -172,7 +172,7 @@ Connection::Connection( const char *desired_ip, const char *desired_port ) /* se if ( desired_ip_addr != INADDR_ANY ) { try { if ( try_bind( sock, desired_ip_addr, desired_port_no ) ) { return; } - } catch ( NetworkException e ) { + } catch ( const NetworkException& e ) { struct in_addr sin_addr; sin_addr.s_addr = desired_ip_addr; fprintf( stderr, "Error binding to IP %s: %s: %s\n", @@ -184,7 +184,7 @@ Connection::Connection( const char *desired_ip, const char *desired_port ) /* se /* now try any local interface */ try { if ( try_bind( sock, INADDR_ANY, desired_port_no ) ) { return; } - } catch ( NetworkException e ) { + } catch ( const NetworkException& e ) { fprintf( stderr, "Error binding to any interface: %s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); throw; /* this time it's fatal */ diff --git a/src/tests/encrypt-decrypt.cc b/src/tests/encrypt-decrypt.cc index 6a74e38..c88bdfb 100644 --- a/src/tests/encrypt-decrypt.cc +++ b/src/tests/encrypt-decrypt.cc @@ -58,7 +58,7 @@ void test_bad_decrypt( Session &decryption_session ) { bool got_exn = false; try { decryption_session.decrypt( bad_ct ); - } catch ( CryptoException e ) { + } catch ( const CryptoException& e ) { got_exn = true; /* The "bad decrypt" exception needs to be non-fatal, otherwise we are @@ -128,7 +128,7 @@ int main( int argc, char *argv[] ) { for ( size_t i=0; i