Author: felix
Date: 2008-10-21 09:56:37 +0200 (Tue, 21 Oct 2008)
New Revision: 1587

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/nessus/comm.c
Log:
* nessus/comm.c (parse_plugin): Removed memory leak (were NULL returns,
without taking care of emalloc'd strings).

M    openvas-client/nessus/comm.c
M    openvas-client/ChangeLog


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog      2008-10-21 07:53:12 UTC (rev 1586)
+++ trunk/openvas-client/ChangeLog      2008-10-21 07:56:37 UTC (rev 1587)
@@ -1,7 +1,16 @@
 2008-10-21  Felix Wolfsteller <[EMAIL PROTECTED]>
 
+       * nessus/comm.c (parse_plugin): Removed memory leak (were NULL returns,
+       without taking care of emalloc'd strings).
+
+2008-10-21  Felix Wolfsteller <[EMAIL PROTECTED]>
+
        * nessus/commc.c (parse_plugin): Peeled if-onion, variable name improved
 
+2008-10-21  Felix Wolfsteller <[EMAIL PROTECTED]>
+
+       * nessus/commc.c (parse_plugin): Peeled if-onion, variable name improved
+
        * nessus/plugin_cache.c: Updated doc/comments about format of nvt 
        cache file.
 

Modified: trunk/openvas-client/nessus/comm.c
===================================================================
--- trunk/openvas-client/nessus/comm.c  2008-10-21 07:53:12 UTC (rev 1586)
+++ trunk/openvas-client/nessus/comm.c  2008-10-21 07:56:37 UTC (rev 1587)
@@ -156,24 +156,25 @@
   else
     return NULL;
 
+  /* Parse all plugin fields. Fail, free memory and return NULL in case of 
error */
   offset = strlen(oid);
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   name = str;
 
   offset += strlen(str) + 5;
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   category = str;
 
   offset += strlen(str) + 5;
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   copyright = str;
 
   offset += strlen(str) + 5;
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   t = str;
   while((t = strchr(t, ';')))
     t[0] = '\n';
@@ -181,36 +182,54 @@
 
   offset += strlen(str) + 5;
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   summary = str;
 
   offset += strlen(str) + 5;
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   family = str;
 
   offset += strlen(str) + 5;
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   version = str;
 
   offset += strlen(str) + 5;
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   cve = str;
-
+  
   offset += strlen(str) + 5;
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   bid = str;
 
   offset += strlen(str) + 5;
   str = parse_separator(buf + offset);
-  if(!str) return NULL;
+  if(!str) goto fail;
   xref = str;
+  
 
   return nessus_plugin_new(oid, name, category, copyright, description,
                            summary, family, version, cve, bid, xref);
+
+fail:
+  {
+  if(oid) efree(&oid);
+  if(name) efree(&name);
+  if(category) efree(&category);
+  if(copyright) efree(&copyright);
+  if(description) efree(&description);
+  if(summary) efree(&summary);
+  if(family) efree(&family);
+  if(version) efree(&version);
+  if(cve) efree(&cve);
+  if(bid) efree(&bid);
+  if(xref) efree(&xref);
+  return NULL;
+  }
+
 }
 
 

_______________________________________________
Openvas-commits mailing list
[email protected]
http://lists.wald.intevation.org/mailman/listinfo/openvas-commits

Reply via email to