]> WPIA git - cassiopeia.git/commitdiff
fix: add catch-all block around main in signer
authorFlorian Weber <oss@florianjw.de>
Sat, 6 Jun 2015 14:55:01 +0000 (16:55 +0200)
committerBenny Baumann <BenBE@geshi.org>
Sun, 7 Jun 2015 11:38:23 +0000 (13:38 +0200)
This fixes the problem that destructors aren't called during
stack-unwinding, if the exception in question is never caught,
which might in the worst-case prevent the wiping of private keys.

src/apps/signer.cpp

index 0d027c0a8070a44823aec9f70adf3399fed96211..baa45c72fef8865e170326b7ab5b3f1a755db8c0 100644 (file)
@@ -1,6 +1,7 @@
 #include <iostream>
 #include <fstream>
 #include <streambuf>
+#include <stdexcept>
 
 #include "db/database.h"
 #include "db/mysql.h"
@@ -21,7 +22,7 @@
 
 extern std::string serialPath;
 
-int main( int argc, const char* argv[] ) {
+int main( int argc, const char* argv[] ) try {
     ( void ) argc;
     ( void ) argv;
 
@@ -63,4 +64,11 @@ int main( int argc, const char* argv[] ) {
     }
 
     return -1;
+
+} catch(std::exception& e) {
+    std::cerr << "Fatal Error: " << e.what() << "!\n";
+    return -1;
+} catch(...) {
+    std::cerr << "Fatal Error: Unknown Exception!\n";
+    return -1;
 }