[Openvas-commits] r5679 - in trunk/gsa: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 23 08:19:40 CEST 2009


Author: jan
Date: 2009-10-23 08:19:39 +0200 (Fri, 23 Oct 2009)
New Revision: 5679

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
Log:
* src/gsad.c (request_handler): Fix call of gsad_newtask,
use g_strconcat.
(gsad_init): Init glib.
(main): Adjust logging to avoid recursion.



Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2009-10-23 05:56:31 UTC (rev 5678)
+++ trunk/gsa/ChangeLog	2009-10-23 06:19:39 UTC (rev 5679)
@@ -1,5 +1,12 @@
 2009-10-23  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
 
+	* src/gsad.c (request_handler): Fix call of gsad_newtask,
+	use g_strconcat.
+	(gsad_init): Init glib.
+	(main): Adjust logging to avoid recursion.
+
+2009-10-23  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
 	* src/gsad.c (send_http_authenticate_header): New.
 
 2009-10-22  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2009-10-23 05:56:31 UTC (rev 5678)
+++ trunk/gsa/src/gsad.c	2009-10-23 06:19:39 UTC (rev 5679)
@@ -88,11 +88,11 @@
 /**
  * @brief HTTP request handler for GSAD.
  *
- * @param[in]  cls              Not used for this callback. 
+ * @param[in]  cls              Not used for this callback.
  * @param[in]  connection       Connection handle, e.g. used to send response.
  * @param[in]  url              The URL requested.
  * @param[in]  method           "GET" or "POST", others are disregarded.
- * @param[in]  version          Not used for this callback. 
+ * @param[in]  version          Not used for this callback.
  * @param[in]  upload_data      Data used for POST requests.
  * @param[in]  upload_data_size Size of upload_data.
  * @param[out] con_cls          For exhange of connection-related data
@@ -222,7 +222,7 @@
                     strlen ("/new_task.html"))) /* flawfinder: ignore,
                                                    it is a const str */
         {
-          res = gsad_newtask (credentials);
+          res = gsad_newtask (credentials, NULL);
           response = MHD_create_response_from_data (strlen (res), res,
                                                     MHD_NO, MHD_YES);
           ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
@@ -234,13 +234,7 @@
        * so it is a simple file. */
 
       /* FIXME: validation, URL length restriction */
-      /* flawfinder: ignore, it is a const str */
-      int len = strlen (GSA_STATE_DIR)
-                + strlen (url) + 1;
-      path = malloc (len);
-      snprintf (path, len, "%s%s", GSA_STATE_DIR, url); /* flawfinder: ignore,
-                                                           snprintf OK for the
-                                                           scope */
+      path = g_strconcat (GSA_STATE_DIR, url, NULL);
       file = fopen (path, "r"); /* flawfinder: ignore, this file is just
                                    read and sent */
 
@@ -248,12 +242,8 @@
       if (file == NULL)
         {
           tracef ("File %s failed, ", path);
-          /* flawfinder: ignore, it is a const str */
-          len = strlen (GSA_STATE_DIR)
-                + strlen (default_file) + 1);
-          path = realloc (path, len);
-          /* flawfinder: ignore, snprintf OK for the scope */
-          snprintf (path, len, "%s%s", GSA_STATE_DIR, default_file);
+          g_free (path);
+          path = g_strconcat (GSA_STATE_DIR, default_file, NULLl);
           tracef ("trying default file <%s>.\n", path);
           file = fopen (path, "r"); /* flawfinder: ignore, this file is just
                                        read and sent */
@@ -275,7 +265,7 @@
               g_critical ("%s: file <%s> can not be stat'ed.\n",
                           __FUNCTION__,
                           path);
-              free (path);
+              g_free (path);
               return MHD_NO;
             }
 
@@ -287,7 +277,7 @@
           ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
 
           MHD_destroy_response (response);
-          free (path);
+          g_free (path);
           return MHD_YES;
         }
     }
@@ -342,6 +332,9 @@
 {
   tracef ("Initializing the Greenbone Security Assistant...\n");
 
+  /* Init Glib. */
+  if (!g_thread_supported ()) g_thread_init (NULL);
+
   /* Check for required files. */
   if (check_is_dir (GSA_STATE_DIR) < 1)
     {
@@ -526,12 +519,9 @@
     log_config = load_log_configuration (rc_name);
   g_free (rc_name);
   setup_log_handlers (log_config);
-  g_log_set_handler (G_LOG_DOMAIN, ALL_LOG_LEVELS,
-                     openvas_log_func, log_config);
-  g_log_set_handler ("gsad  omp", ALL_LOG_LEVELS,
-                     openvas_log_func, log_config);
-  g_log_set_handler (NULL, ALL_LOG_LEVELS,
-                     openvas_log_func, log_config);
+  /* Set to ensure that recursion is left out, in case two threads log
+   * concurrently. */
+  g_log_set_always_fatal (G_LOG_FATAL_MASK);
 
   /* Finish processing the command line options */
 



More information about the Openvas-commits mailing list