library initialization fails if libstrongswan checksum is invalid
authorMartin Willi <martin@strongswan.org>
Fri, 19 Jun 2009 10:01:52 +0000 (12:01 +0200)
committerMartin Willi <martin@strongswan.org>
Mon, 22 Jun 2009 13:47:17 +0000 (15:47 +0200)
src/charon/daemon.c
src/libstrongswan/library.c
src/libstrongswan/library.h
src/pluto/plutomain.c

index c646ef9..f6f3ac1 100644 (file)
@@ -686,7 +686,10 @@ int main(int argc, char *argv[])
        dbg = dbg_stderr;
        
        /* initialize library */
-       library_init(STRONGSWAN_CONF);
+       if (!library_init(STRONGSWAN_CONF))
+       {
+               exit(-1);
+       }
        lib->printf_hook->add_handler(lib->printf_hook, 'R',
                                                                  traffic_selector_printf_hook,
                                                                  PRINTF_HOOK_ARGTYPE_POINTER,
index ae2d8a9..217dbc0 100644 (file)
@@ -86,7 +86,7 @@ void library_deinit()
 /*
  * see header file
  */
-void library_init(char *settings)
+bool library_init(char *settings)
 {
        printf_hook_t *pfh;
        private_library_t *this = malloc_thing(private_library_t);
@@ -136,7 +136,9 @@ void library_init(char *settings)
                                                                                  "libstrongswan", library_init))
                {
                        DBG1("integrity check of libstrongswan failed");
+                       return FALSE;
                }
        }
+       return TRUE;
 }
 
index f1cbb90..3f62b24 100644 (file)
@@ -123,8 +123,9 @@ struct library_t {
  * Initialize library, creates "lib" instance.
  *
  * @param settings             file to read settings from, may be NULL for none
+ * @return                             FALSE if integrity check failed
  */
-void library_init(char *settings);
+bool library_init(char *settings);
 
 /**
  * Deinitialize library, destroys "lib" instance.
index 39367ca..a9377cb 100644 (file)
@@ -265,7 +265,10 @@ int main(int argc, char **argv)
 #endif /* CAPABILITIES */
 
        /* initialize library and optionsfrom */
-       library_init(STRONGSWAN_CONF);
+       if (!library_init(STRONGSWAN_CONF))
+       {
+               abort();
+       }
        options = options_create();
 
        /* handle arguments */