Hello community,

here is the log from the commit of package libopenvas for openSUSE:Factory
checked in at Mon May 9 09:39:25 CEST 2011.



--------
--- libopenvas/libopenvas.changes       2011-03-18 16:16:19.000000000 +0100
+++ /mounts/work_src_done/STABLE/libopenvas/libopenvas.changes  2011-05-07 
12:49:46.000000000 +0200
@@ -1,0 +2,10 @@
+Sat May  7 10:29:26 UTC 2011 - [email protected]
+
+- Update to 4.0.4
+  * The handling of internal dependencies while linking has been improved,
+    parallel builds of openvas-libraries should now work.
+  * Two potential resource leaks reported by Pavel Sejnoha and Henri Doreau 
have
+    been fixed.
+  * The setting "unscanned_closed" is now properly applied to UDP ports.
+
+-------------------------------------------------------------------

calling whatdependson for head-i586


Old:
----
  openvas-libraries-4.0.3.tar.gz

New:
----
  openvas-libraries-4.0.4.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libopenvas.spec ++++++
--- /var/tmp/diff_new_pack.lie2AP/_old  2011-05-09 09:38:55.000000000 +0200
+++ /var/tmp/diff_new_pack.lie2AP/_new  2011-05-09 09:38:55.000000000 +0200
@@ -20,7 +20,7 @@
 %define soname 4
 
 Name:           libopenvas
-Version:        4.0.3
+Version:        4.0.4
 Release:        1
 License:        GPLv2
 Group:          Productivity/Networking/Security
@@ -156,8 +156,7 @@
 
 %build
 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_VERBOSE_MAKEFILE=ON 
-DSYSCONFDIR=%{_sysconfdir} -DLOCALSTATEDIR=%{_localstatedir} 
-DLIBDIR=%{_libdir} -DBUILD_WITH_LDAP=ON -DCMAKE_BUILD_TYPE=release
-#__make %{?_smp_mflags} VERBOSE=1
-make VERBOSE=1
+%__make %{?_smp_mflags} VERBOSE=1
 
 %install
 %__make install DESTDIR=%{buildroot}

++++++ debian.changelog ++++++
--- /var/tmp/diff_new_pack.lie2AP/_old  2011-05-09 09:38:55.000000000 +0200
+++ /var/tmp/diff_new_pack.lie2AP/_new  2011-05-09 09:38:55.000000000 +0200
@@ -1,3 +1,14 @@
+libopenvas (4.0.4-1) unstable; urgency=low
+
+  * New upstream release.
+    - The handling of internal dependencies while linking has been improved,
+      parallel builds of openvas-libraries should now work.
+    - Two potential resource leaks reported by Pavel Sejnoha and Henri Doreau 
have
+      been fixed.
+    - The setting "unscanned_closed" is now properly applied to UDP ports.
+
+ -- Stephan Kleine <[email protected]>  Sat, 07 May 2011 12:30:32 +0200
+
 libopenvas (4.0.3-1) unstable; urgency=low
 
   * New upstream release.

++++++ libopenvas.dsc ++++++
--- /var/tmp/diff_new_pack.lie2AP/_old  2011-05-09 09:38:55.000000000 +0200
+++ /var/tmp/diff_new_pack.lie2AP/_new  2011-05-09 09:38:55.000000000 +0200
@@ -2,13 +2,13 @@
 Source: libopenvas
 Binary: libopenvas4-dev, libopenvas4
 Architecture: any
-Version: 4.0.3-1
+Version: 4.0.4-1
 Maintainer: Stephan Kleine <[email protected]>
 Homepage: http://www.openvas.org/
 Standards-Version: 3.8.0
 Build-Depends: bison, cmake (>= 2.6), debhelper (>= 5), doxygen, dpatch, 
hardening-wrapper, libgcrypt11-dev, libglib2.0-dev, libgnutls-dev, 
libgpgme11-dev (>= 1.1.2), libldap2-dev, libpcap-dev, uuid-dev
 
 Files: 
- b55a7a72ba7b9c8da7b1372a91fbdf88 464106 libopenvas-4.0.3.tar.gz
- f657b454af293e32275da3400cc7c67b 4369 libopenvas-4.0.3.diff.gz
+ b55a7a72ba7b9c8da7b1372a91fbdf88 464106 libopenvas-4.0.4.tar.gz
+ f657b454af293e32275da3400cc7c67b 4369 libopenvas-4.0.4.diff.gz
 

++++++ openvas-libraries-4.0.3.tar.gz -> openvas-libraries-4.0.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/CHANGES 
new/openvas-libraries-4.0.4/CHANGES
--- old/openvas-libraries-4.0.3/CHANGES 2011-03-03 09:44:22.000000000 +0100
+++ new/openvas-libraries-4.0.4/CHANGES 2011-05-04 08:22:37.000000000 +0200
@@ -1,3 +1,23 @@
+openvas-libraries 4.0.4 (2011-05-04)
+
+This is the fourth maintenance release of the openvas-libraries 4.0 module for
+the Open Vulnerability Assessment System (OpenVAS).
+
+This release features improvements to the build environment, closes two
+potential resource leaks and ensures the unscanned_closed setting in honored 
for
+UDP ports as well.
+
+Many thanks to everyone who has contributed this release:
+Henri Doreau, Matthew Mundell, Pavel Sejnoha and Michael Wiegand.
+
+Main changes compared to 4.0.3:
+* The handling of internal dependencies while linking has been improved,
+  parallel builds of openvas-libraries should now work.
+* Two potential resource leaks reported by Pavel Sejnoha and Henri Doreau have
+  been fixed.
+* The setting "unscanned_closed" is now properly applied to UDP ports.
+
+
 openvas-libraries 4.0.3 (2011-03-03)
 
 This is the third maintenance release of the openvas-libraries 4.0 module for
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/CMakeLists.txt 
new/openvas-libraries-4.0.4/CMakeLists.txt
--- old/openvas-libraries-4.0.3/CMakeLists.txt  2011-03-03 09:44:22.000000000 
+0100
+++ new/openvas-libraries-4.0.4/CMakeLists.txt  2011-05-04 08:22:37.000000000 
+0200
@@ -81,7 +81,7 @@
 set (CPACK_TOPLEVEL_TAG "")
 set (CPACK_PACKAGE_VERSION_MAJOR "4")
 set (CPACK_PACKAGE_VERSION_MINOR "0")
-set (CPACK_PACKAGE_VERSION_PATCH "3${SVN_REVISION}")
+set (CPACK_PACKAGE_VERSION_PATCH "4${SVN_REVISION}")
 set (CPACK_PACKAGE_VERSION 
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
 set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
 set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/ChangeLog 
new/openvas-libraries-4.0.4/ChangeLog
--- old/openvas-libraries-4.0.3/ChangeLog       2011-03-03 09:44:22.000000000 
+0100
+++ new/openvas-libraries-4.0.4/ChangeLog       2011-05-04 08:22:37.000000000 
+0200
@@ -1,3 +1,61 @@
+2011-05-04  Michael Wiegand <[email protected]>
+
+       Preparing the openvas-libraries 4.0.4 release.
+
+       * CHANGES: Updated.
+
+2011-04-15  Henri Doreau <[email protected]>
+
+       * nasl/nasl_grammar.y (init_nasl_ctx), nasl/nasl.c (main): fixed memory
+       leaks reported by valgrind.
+
+2011-04-15  Henri Doreau <[email protected]>
+
+       * misc/popen.c (openvas_popen4): replaced raw fd numbers for
+       stdin/stdout/stderr by the corresponding STD*_FILENO macros from
+       unistd.h
+
+2011-04-11  Matthew Mundell <[email protected]>
+
+       * omp/xml.c (try_read_entity_and_string): New function.  Body from
+       read_entity_and_string, with timeout arg.
+       (read_entity_and_string): Call through to try_read_entity_and_string.
+       (try_read_entity): New function.
+       (read_entity): Call through to try_read_entity.
+
+       * omp/omp.c (omp_ping): New function.
+
+       * omp/xml.h, omp/omp.h: Add headers accordingly.
+
+2011-03-19  Matthew Mundell <[email protected]>
+
+       * omp/xml.c (parse_entity): New function.
+
+       * omp/xml.h: Add header accordingly.
+
+2011-03-09  Michael Wiegand <[email protected]>
+
+       * misc/plugutils.c (kb_get_port_state_proto): Honor unscanned_closed
+       setting for UDP ports as well.
+
+2011-03-07  Matthew Mundell <[email protected]>
+
+       * omp/xml.c (handle_end_element, read_entity_and_string): Free context
+       data list elements.  From valgrind by Pavel Sejnoha.
+
+2011-03-07  Michael Wiegand <[email protected]>
+
+       * hg/CMakeLists.txt, misc/CMakeLists.txt, nasl/CMakeLists.txt,
+       omp/CMakeLists.txt: Refer to libraries by their target name to allow
+       cmake to handle dependencies correctly. Add missing link between misc
+       and base when doing static linking.
+
+2011-03-03  Michael Wiegand <[email protected]>
+
+       Post release version bump.
+
+       * CMakeLists.txt: Set version to 4.0.4.
+
 2011-03-03  Michael Wiegand <[email protected]>
 
        Preparing the openvas-libraries 4.0.3 release.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/hg/CMakeLists.txt 
new/openvas-libraries-4.0.4/hg/CMakeLists.txt
--- old/openvas-libraries-4.0.3/hg/CMakeLists.txt       2011-03-03 
09:44:22.000000000 +0100
+++ new/openvas-libraries-4.0.4/hg/CMakeLists.txt       2011-05-04 
08:22:37.000000000 +0200
@@ -51,7 +51,7 @@
 set_target_properties (openvas_hg_shared PROPERTIES SOVERSION 
"${CPACK_PACKAGE_VERSION_MAJOR}")
 set_target_properties (openvas_hg_shared PROPERTIES VERSION 
"${CPACK_PACKAGE_VERSION}")
 set_target_properties (openvas_hg_shared PROPERTIES PUBLIC_HEADER "${HEADERS}")
-target_link_libraries (openvas_hg_shared resolv openvas_misc)
+target_link_libraries (openvas_hg_shared resolv openvas_misc_shared 
openvas_base_shared)
 
 if (OPENVAS_PID_DIR)
   add_definitions (-DOPENVAS_PID_DIR=\\\"${OPENVAS_PID_DIR}\\\")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/misc/CMakeLists.txt 
new/openvas-libraries-4.0.4/misc/CMakeLists.txt
--- old/openvas-libraries-4.0.3/misc/CMakeLists.txt     2011-03-03 
09:44:22.000000000 +0100
+++ new/openvas-libraries-4.0.4/misc/CMakeLists.txt     2011-05-04 
08:22:37.000000000 +0200
@@ -110,6 +110,7 @@
 set_target_properties (openvas_misc_static PROPERTIES OUTPUT_NAME 
"openvas_misc")
 set_target_properties (openvas_misc_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
 set_target_properties (openvas_misc_static PROPERTIES PUBLIC_HEADER 
"${HEADERS}")
+target_link_libraries (openvas_misc_static openvas_base_static)
 
 add_library (openvas_misc_shared SHARED ${FILES})
 
@@ -120,7 +121,7 @@
 set_target_properties (openvas_misc_shared PROPERTIES VERSION 
"${CPACK_PACKAGE_VERSION}")
 set_target_properties (openvas_misc_shared PROPERTIES PUBLIC_HEADER 
"${HEADERS}")
 if (NOT MINGW)
-  target_link_libraries (openvas_misc_shared glib-2.0 pcap gnutls gcrypt 
openvas_base)
+  target_link_libraries (openvas_misc_shared glib-2.0 pcap gnutls gcrypt 
openvas_base_shared)
 endif (NOT MINGW)
 
 if (OPENVASLIB_VERSION)
@@ -160,10 +161,10 @@
 endif (OPENVAS_SYSCONF_DIR)
 
 if (MINGW)
-  target_link_libraries (openvas_misc_static uuid openvas_base ${GLIB_LDFLAGS} 
-lglib-2.0
+  target_link_libraries (openvas_misc_static uuid openvas_base_static 
${GLIB_LDFLAGS} -lglib-2.0
                          -lgcrypt -lgnutls -lintl -liconv -lgpg-error -lws2_32
                          -lole32 -lz)
-  target_link_libraries (openvas_misc_shared uuid openvas_base ${GLIB_LDFLAGS} 
-lglib-2.0
+  target_link_libraries (openvas_misc_shared uuid openvas_base_shared 
${GLIB_LDFLAGS} -lglib-2.0
                          -lgcrypt -lgnutls -lintl -liconv -lgpg-error -lws2_32
                          -lole32 -lz)
 else (MINGW)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/misc/plugutils.c 
new/openvas-libraries-4.0.4/misc/plugutils.c
--- old/openvas-libraries-4.0.3/misc/plugutils.c        2011-03-03 
09:44:22.000000000 +0100
+++ new/openvas-libraries-4.0.4/misc/plugutils.c        2011-05-04 
08:22:37.000000000 +0200
@@ -738,7 +738,7 @@
     return unscanned_ports_as_closed (prefs);
   else if (!strcmp (proto, "udp")
            && kb_item_get_int (kb, "Host/udp_scanned") <= 0)
-    return 1;
+    return unscanned_ports_as_closed (prefs);
 
   range = (u_short *) getpts (prange, &num);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/misc/popen.c 
new/openvas-libraries-4.0.4/misc/popen.c
--- old/openvas-libraries-4.0.3/misc/popen.c    2011-03-03 09:44:22.000000000 
+0100
+++ new/openvas-libraries-4.0.4/misc/popen.c    2011-05-04 08:22:37.000000000 
+0200
@@ -98,19 +98,19 @@
           perror ("/dev/null");
           exit (1);
         }
-      close (0);
-      if (dup2 (fd, 0) < 0)
+      close (STDIN_FILENO);
+      if (dup2 (fd, STDIN_FILENO) < 0)
         {
           perror ("dup2");
           exit (1);
         }
       close (fd);
 
-      close (1);
-      close (2);
-      if (dup2 (pipes[1], 1) < 0 || dup2 (pipes[1], 2) < 0)
+      close (STDOUT_FILENO);
+      close (STDERR_FILENO);
+      if (dup2 (pipes[1], STDOUT_FILENO) < 0 || dup2 (pipes[1], STDERR_FILENO) 
< 0)
         {
-          /* Cannot print error as 2 is closed! */
+          /* Cannot print error as STDERR is closed! */
           exit (1);
         }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/nasl/CMakeLists.txt 
new/openvas-libraries-4.0.4/nasl/CMakeLists.txt
--- old/openvas-libraries-4.0.3/nasl/CMakeLists.txt     2011-03-03 
09:44:22.000000000 +0100
+++ new/openvas-libraries-4.0.4/nasl/CMakeLists.txt     2011-05-04 
08:22:37.000000000 +0200
@@ -98,8 +98,8 @@
 set_target_properties (openvas_nasl_static PROPERTIES OUTPUT_NAME 
"openvas_nasl")
 set_target_properties (openvas_nasl_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
 set_target_properties (openvas_nasl_static PROPERTIES PUBLIC_HEADER 
"${HEADERS}")
-target_link_libraries (openvas_nasl_static openvas_base openvas_misc
-                       openvas_hg glib-2.0 gcrypt gpgme
+target_link_libraries (openvas_nasl_static openvas_base_static 
openvas_misc_static
+                       openvas_hg_static glib-2.0 gcrypt gpgme
                        gpg-error gnutls pcap ${WMI})
 
 add_library (openvas_nasl_shared SHARED ${FILES})
@@ -110,14 +110,14 @@
 set_target_properties (openvas_nasl_shared PROPERTIES VERSION 
"${CPACK_PACKAGE_VERSION}")
 set_target_properties (openvas_nasl_shared PROPERTIES PUBLIC_HEADER 
"${HEADERS}")
 # line bellow is needed so it also works with no-undefined which is e.g. used 
by Mandriva
-target_link_libraries (openvas_nasl_shared openvas_base openvas_misc
-                       openvas_hg glib-2.0 gcrypt gpgme
+target_link_libraries (openvas_nasl_shared openvas_base_shared 
openvas_misc_shared
+                       openvas_hg_shared glib-2.0 gcrypt gpgme
                        gpg-error gnutls pcap m ${WMI})
 
 # Link the openvas-nasl executable
 add_executable (openvas-nasl nasl.c)
-target_link_libraries (openvas-nasl openvas_nasl_static openvas_base
-                       openvas_misc openvas_hg ${GLIB_LDFLAGS} -lgcrypt
+target_link_libraries (openvas-nasl openvas_nasl_static openvas_base_static
+                       openvas_misc_static openvas_hg_static ${GLIB_LDFLAGS} 
-lgcrypt
                        -lgpgme -lgpg-error -lgnutls -lpcap -lresolv -lm 
${WMI_LIBS})
 set_target_properties (openvas-nasl PROPERTIES COMPILE_FLAGS
                        "${GLIB_CFLAGS} ${GPGME_CFLAGS}")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/nasl/nasl.c 
new/openvas-libraries-4.0.4/nasl/nasl.c
--- old/openvas-libraries-4.0.3/nasl/nasl.c     2011-03-03 09:44:22.000000000 
+0100
+++ new/openvas-libraries-4.0.4/nasl/nasl.c     2011-05-04 08:22:37.000000000 
+0200
@@ -161,6 +161,7 @@
       g_print ("%s\n\n", error->message);
       exit (0);
     }
+  g_option_context_free (option_context);
  /*--------------------------------------------
        Command-line options
   ---------------------------------------------*/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/nasl/nasl_grammar.y 
new/openvas-libraries-4.0.4/nasl/nasl_grammar.y
--- old/openvas-libraries-4.0.3/nasl/nasl_grammar.y     2011-03-03 
09:44:22.000000000 +0100
+++ new/openvas-libraries-4.0.4/nasl/nasl_grammar.y     2011-05-04 
08:22:37.000000000 +0200
@@ -557,6 +557,8 @@
   pc->fp = NULL;
 
   while (inc_dir != NULL) {
+    if (full_name)
+      g_free (full_name);
     full_name = g_build_filename(inc_dir->data, name, NULL);
 
     if ((pc->fp = fopen(full_name, "r")) != NULL)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/omp/CMakeLists.txt 
new/openvas-libraries-4.0.4/omp/CMakeLists.txt
--- old/openvas-libraries-4.0.3/omp/CMakeLists.txt      2011-03-03 
09:44:22.000000000 +0100
+++ new/openvas-libraries-4.0.4/omp/CMakeLists.txt      2011-05-04 
08:22:37.000000000 +0200
@@ -51,11 +51,11 @@
 set_target_properties (openvas_omp_shared PROPERTIES PUBLIC_HEADER 
"${HEADERS}")
 
 if (MINGW)
-  target_link_libraries (openvas_omp_shared openvas_misc -lglib-2.0 -lgnutls
+  target_link_libraries (openvas_omp_shared openvas_misc_shared -lglib-2.0 
-lgnutls
                          -lgcrypt -lgpg-error -lintl -lws2_32 -liconv -lole32
                          -lz -lkernel32)
 else (MINGW)
-  target_link_libraries (openvas_omp_shared openvas_misc glib-2.0 gnutls)
+  target_link_libraries (openvas_omp_shared openvas_misc_shared glib-2.0 
gnutls)
 endif (MINGW)
 
 ## Install
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/omp/omp.c 
new/openvas-libraries-4.0.4/omp/omp.c
--- old/openvas-libraries-4.0.3/omp/omp.c       2011-03-03 09:44:22.000000000 
+0100
+++ new/openvas-libraries-4.0.4/omp/omp.c       2011-05-04 08:22:37.000000000 
+0200
@@ -120,6 +120,62 @@
 }
 
 /**
+ * @brief "Ping" the manager.
+ *
+ * @param[in]  session   Pointer to GNUTLS session.
+ * @param[in]  timeout   Server idle time before giving up, in milliseconds.  0
+ *                       to wait forever.
+ *
+ * @return 0 on success, 1 if manager closed connection, 2 on timeout,
+ *         -1 on error.
+ */
+int
+omp_ping (gnutls_session_t *session, int timeout)
+{
+  entity_t entity;
+  const char* status;
+  char first;
+  int ret;
+
+  /* Send a GET_VERSION request. */
+
+  ret = openvas_server_send (session, "<get_version/>");
+  if (ret)
+    return ret;
+
+  /* Read the response, with a timeout. */
+
+  entity = NULL;
+  switch (try_read_entity (session, timeout, &entity))
+    {
+      case 0:
+        break;
+      case -4:
+        return 2;
+      default:
+        return -1;
+    }
+
+  /* Check the response. */
+
+  status = entity_attribute (entity, "status");
+  if (status == NULL)
+    {
+      free_entity (entity);
+      return -1;
+    }
+  if (strlen (status) == 0)
+    {
+      free_entity (entity);
+      return -1;
+    }
+  first = status[0];
+  free_entity (entity);
+  if (first == '2') return 0;
+  return -1;
+}
+
+/**
  * @brief Authenticate with the manager.
  *
  * @param[in]  session   Pointer to GNUTLS session.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/omp/omp.h 
new/openvas-libraries-4.0.4/omp/omp.h
--- old/openvas-libraries-4.0.3/omp/omp.h       2011-03-03 09:44:22.000000000 
+0100
+++ new/openvas-libraries-4.0.4/omp/omp.h       2011-05-04 08:22:37.000000000 
+0200
@@ -42,6 +42,8 @@
 
 const char *omp_task_status (entity_t status_response);
 
+int omp_ping (gnutls_session_t *, int);
+
 int omp_get_nvt_all (gnutls_session_t * session, entity_t * response);
 
 int omp_get_nvt_feed_checksum (gnutls_session_t * session, entity_t * 
response);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/omp/xml.c 
new/openvas-libraries-4.0.4/omp/xml.c
--- old/openvas-libraries-4.0.3/omp/xml.c       2011-03-03 09:44:22.000000000 
+0100
+++ new/openvas-libraries-4.0.4/omp/xml.c       2011-05-04 08:22:37.000000000 
+0200
@@ -37,9 +37,12 @@
  */
 
 #include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
 #include <glib.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "xml.h"
 
@@ -358,10 +361,17 @@
                       /* The name of the very first entity. */
                       ((entity_t) (data->first->data))->name) == 0);
       data->done = TRUE;
+      /* "Pop" the element. */
+      data->current = g_slist_next (data->current);
+    }
+  else if (data->current)
+    {
+      GSList *front;
+      /* "Pop" and free the element. */
+      front = data->current;
+      data->current = g_slist_next (data->current);
+      g_slist_free_1 (front);
     }
-  /* "Pop" the element. */
-  if (data->current)
-    data->current = g_slist_next (data->current);
 }
 
 /**
@@ -397,9 +407,11 @@
 }
 
 /**
- * @brief Read an XML entity tree from the manager.
+ * @brief Try read an XML entity tree from the manager.
  *
  * @param[in]   session   Pointer to GNUTLS session.
+ * @param[in]   timeout   Server idle time before giving up, in seconds.  0 to
+ *                        wait forever.
  * @param[out]  entity    Pointer to an entity tree.
  * @param[out]  string    An optional return location for the text read
  *                        from the session.  If NULL then it simply
@@ -408,16 +420,41 @@
  *                        Otherwise it points to an existing GString onto
  *                        which the text is appended.
  *
- * @return 0 success, -1 read error, -2 parse error, -3 end of file.
+ * @return 0 success, -1 read error, -2 parse error, -3 end of file, -4 
timeout.
  */
 int
-read_entity_and_string (gnutls_session_t * session, entity_t * entity,
-                        GString ** string_return)
+try_read_entity_and_string (gnutls_session_t * session, int timeout,
+                            entity_t * entity, GString ** string_return)
 {
   GMarkupParser xml_parser;
   GError *error = NULL;
   GMarkupParseContext *xml_context;
   GString *string;
+  int socket;
+  time_t last_time;
+
+  /* Record the start time. */
+
+  if (time (&last_time) == -1)
+    {
+      g_message ("   failed to get current time: %s\n",
+                 strerror (errno));
+      return -1;
+    }
+
+  if (timeout > 0)
+    {
+      /* Turn off blocking. */
+
+      socket = GPOINTER_TO_INT (gnutls_transport_get_ptr (*session));
+      if (fcntl (socket, F_SETFL, O_NONBLOCK) == -1)
+        return -1;
+    }
+  else
+    /* Quiet compiler. */
+    socket = 0;
+
+  /* Setup return arg. */
 
   if (string_return == NULL)
     string = NULL;
@@ -460,13 +497,30 @@
               if (count == GNUTLS_E_INTERRUPTED)
                 /* Interrupted, try read again. */
                 continue;
+              if ((timeout > 0) && (count == GNUTLS_E_AGAIN))
+                {
+                  /* Server still busy, either timeout and try read again. */
+                  if ((timeout - (time (NULL) - last_time))
+                      <= 0)
+                    {
+                      g_message ("   timeout\n");
+                      fcntl (socket, F_SETFL, 0L);
+                      return -4;
+                    }
+                  continue;
+                }
               if (count == GNUTLS_E_REHANDSHAKE)
                 /* Try again. TODO Rehandshake. */
                 continue;
               if (context_data.first && context_data.first->data)
-                free_entity (context_data.first->data);
+                {
+                  free_entity (context_data.first->data);
+                  g_slist_free_1 (context_data.first);
+                }
               if (string && *string_return == NULL)
                 g_string_free (string, TRUE);
+              if (timeout > 0)
+                fcntl (socket, F_SETFL, 0L);
               return -1;
             }
           if (count == 0)
@@ -479,9 +533,14 @@
                   g_error_free (error);
                 }
               if (context_data.first && context_data.first->data)
-                free_entity (context_data.first->data);
+                {
+                  free_entity (context_data.first->data);
+                  g_slist_free_1 (context_data.first);
+                }
               if (string && *string_return == NULL)
                 g_string_free (string, TRUE);
+              if (timeout > 0)
+                fcntl (socket, F_SETFL, 0L);
               return -3;
             }
           break;
@@ -497,9 +556,14 @@
         {
           g_error_free (error);
           if (context_data.first && context_data.first->data)
-            free_entity (context_data.first->data);
+            {
+              free_entity (context_data.first->data);
+              g_slist_free_1 (context_data.first);
+            }
           if (string && *string_return == NULL)
             g_string_free (string, TRUE);
+          if (timeout > 0)
+            fcntl (socket, F_SETFL, 0L);
           return -2;
         }
       if (context_data.done)
@@ -510,18 +574,56 @@
               g_message ("   End error: %s\n", error->message);
               g_error_free (error);
               if (context_data.first && context_data.first->data)
-                free_entity (context_data.first->data);
+                {
+                  free_entity (context_data.first->data);
+                  g_slist_free_1 (context_data.first);
+                }
+              if (timeout > 0)
+                fcntl (socket, F_SETFL, 0L);
               return -2;
             }
           *entity = (entity_t) context_data.first->data;
           if (string)
             *string_return = string;
+          if (timeout > 0)
+            fcntl (socket, F_SETFL, 0L);
           return 0;
         }
+
+      if ((timeout > 0) && (time (&last_time) == -1))
+        {
+          g_message ("   failed to get current time (1): %s\n",
+                     strerror (errno));
+          fcntl (socket, F_SETFL, 0L);
+          return -1;
+        }
     }
 }
 
 /**
+ * @brief Try read an XML entity tree from the manager.
+ *
+ * @param[in]   session   Pointer to GNUTLS session.
+ * @param[in]   timeout   Seconds or server idle time before giving up.  0 to
+ *                        wait forever.
+ * @param[out]  entity    Pointer to an entity tree.
+ * @param[out]  string    An optional return location for the text read
+ *                        from the session.  If NULL then it simply
+ *                        remains NULL.  If a pointer to NULL then it points
+ *                        to a freshly allocated GString on successful return.
+ *                        Otherwise it points to an existing GString onto
+ *                        which the text is appended.
+ *
+ * @return 0 success, -1 read error, -2 parse error, -3 end of file, -4 
timeout.
+ */
+int
+read_entity_and_string (gnutls_session_t * session, entity_t * entity,
+                        GString ** string_return)
+{
+  return try_read_entity_and_string (session, 0, entity, string_return);
+}
+
+/**
  * @brief Read an XML entity tree from the manager.
  *
  * @param[in]   session   Pointer to GNUTLS session.
@@ -571,6 +673,22 @@
 }
 
 /**
+ * @brief Try read an XML entity tree from the manager.
+ *
+ * @param[in]   session   Pointer to GNUTLS session.
+ * @param[in]   timeout   Server idle time before giving up, in seconds.  0 to
+ *                        wait forever.
+ * @param[out]  entity    Pointer to an entity tree.
+ *
+ * @return 0 success, -1 read error, -2 parse error, -3 end of file.
+ */
+int
+try_read_entity (gnutls_session_t * session, int timeout, entity_t * entity)
+{
+  return try_read_entity_and_string (session, timeout, entity, NULL);
+}
+
+/**
  * @brief Read an XML entity tree from the manager.
  *
  * @param[in]   session   Pointer to GNUTLS session.
@@ -581,7 +699,79 @@
 int
 read_entity (gnutls_session_t * session, entity_t * entity)
 {
-  return read_entity_and_string (session, entity, NULL);
+  return try_read_entity (session, 0, entity);
+}
+
+/**
+ * @brief Read an XML entity tree from a string.
+ *
+ * @param[in]   string  Input string.
+ * @param[out]  entity  Pointer to an entity tree.
+ *
+ * @return 0 success, -1 read error, -2 parse error, -3 XML ended prematurely.
+ */
+int
+parse_entity (const char *string, entity_t * entity)
+{
+  GMarkupParser xml_parser;
+  GError *error = NULL;
+  GMarkupParseContext *xml_context;
+  context_data_t context_data;
+
+  /* Create the XML parser. */
+
+  xml_parser.start_element = handle_start_element;
+  xml_parser.end_element = handle_end_element;
+  xml_parser.text = handle_text;
+  xml_parser.passthrough = NULL;
+  xml_parser.error = handle_error;
+
+  context_data.done = FALSE;
+  context_data.first = NULL;
+  context_data.current = NULL;
+
+  /* Setup the XML context. */
+
+  xml_context =
+    g_markup_parse_context_new (&xml_parser, 0, &context_data, NULL);
+
+  /* Parse the string. */
+
+  g_markup_parse_context_parse (xml_context, string, strlen (string), &error);
+  if (error)
+    {
+      g_error_free (error);
+      if (context_data.first && context_data.first->data)
+        {
+          free_entity (context_data.first->data);
+          g_slist_free_1 (context_data.first);
+        }
+      return -2;
+    }
+  if (context_data.done)
+    {
+      g_markup_parse_context_end_parse (xml_context, &error);
+      if (error)
+        {
+          g_message ("   End error: %s\n", error->message);
+          g_error_free (error);
+          if (context_data.first && context_data.first->data)
+            {
+              free_entity (context_data.first->data);
+              g_slist_free_1 (context_data.first);
+            }
+          return -2;
+        }
+      *entity = (entity_t) context_data.first->data;
+      g_slist_free_1 (context_data.first);
+      return 0;
+    }
+  if (context_data.first && context_data.first->data)
+    {
+      free_entity (context_data.first->data);
+      g_slist_free_1 (context_data.first);
+    }
+  return -3;
 }
 
 /**
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openvas-libraries-4.0.3/omp/xml.h 
new/openvas-libraries-4.0.4/omp/xml.h
--- old/openvas-libraries-4.0.3/omp/xml.h       2011-03-03 09:44:22.000000000 
+0100
+++ new/openvas-libraries-4.0.4/omp/xml.h       2011-05-04 08:22:37.000000000 
+0200
@@ -80,14 +80,21 @@
 
 void print_entities_format (entities_t, int indentation);
 
+int try_read_entity_and_string (gnutls_session_t *, int, entity_t *,
+                                GString **);
+
 int read_entity_and_string (gnutls_session_t *, entity_t *, GString **);
 
 int read_entity_and_text (gnutls_session_t *, entity_t *, char **);
 
+int try_read_entity (gnutls_session_t *, int, entity_t *);
+
 int read_entity (gnutls_session_t *, entity_t *);
 
 int read_string (gnutls_session_t *, GString **);
 
+int parse_entity (const char *, entity_t *);
+
 void print_entity_to_string (entity_t entity, GString * string);
 
 void print_entities_to_string (GString * string, entities_t entities);


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to