Author: kroosec
Date: 2016-10-17 13:10:37 +0200 (Mon, 17 Oct 2016)
New Revision: 26413

Modified:
   trunk/openvas-libraries/ChangeLog
   trunk/openvas-libraries/nasl/nasl_misc_funcs.c
   trunk/openvas-libraries/nasl/nasl_var.c
   trunk/openvas-libraries/nasl/nasl_var.h
Log:
* nasl/nasl_var.c (nasl_get_var_by_num): Add lexic context to
nasl_perror() call.
(get_array_elem): Adjust nasl_get_var_by_num() call.

* nasl/nasl_var.h: Adjust function header.

* nasl/nasl_misc_funcs.c (nasl_make_list, nasl_make_array, nasl_keys)
(nasl_make_index, nasl_typeof): Adjust nasl_get_var_by_num() call.

Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog   2016-10-14 15:42:24 UTC (rev 26412)
+++ trunk/openvas-libraries/ChangeLog   2016-10-17 11:10:37 UTC (rev 26413)
@@ -1,3 +1,15 @@
+2016-10-17  Hani Benhabiles <hani.benhabi...@greenbone.net>
+
+       * nasl/nasl_var.c (nasl_get_var_by_num): Add lexic context to
+       nasl_perror() call.
+       (get_array_elem): Adjust nasl_get_var_by_num() call.
+
+       * nasl/nasl_var.h: Adjust function header.
+
+       * nasl/nasl_misc_funcs.c (nasl_make_list, nasl_make_array, nasl_keys)
+       (nasl_make_index, nasl_typeof): Adjust nasl_get_var_by_num() call.
+
+
 2016-10-07  Hani Benhabiles <hani.benhabi...@greenbone.net>
 
        * base/gpgme_util.c (openvas_init_gpgme_ctx): Fix memory leak.

Modified: trunk/openvas-libraries/nasl/nasl_misc_funcs.c
===================================================================
--- trunk/openvas-libraries/nasl/nasl_misc_funcs.c      2016-10-14 15:42:24 UTC 
(rev 26412)
+++ trunk/openvas-libraries/nasl/nasl_misc_funcs.c      2016-10-17 11:10:37 UTC 
(rev 26413)
@@ -387,7 +387,7 @@
   retc->type = DYN_ARRAY;
   retc->x.ref_val = a = g_malloc0 (sizeof (nasl_array));
 
-  for (i = vi = 0; (v = nasl_get_var_by_num (&lexic->ctx_vars, vi, 0)) != NULL;
+  for (i = vi = 0; (v = nasl_get_var_by_num (lexic, &lexic->ctx_vars, vi, 0)) 
!= NULL;
        vi++)
     {
       switch (v->var_type)
@@ -457,9 +457,9 @@
   retc->x.ref_val = a = g_malloc0 (sizeof (nasl_array));
 
   vi = 0;
-  while ((v = nasl_get_var_by_num (&lexic->ctx_vars, vi++, 0)) != NULL)
+  while ((v = nasl_get_var_by_num (lexic, &lexic->ctx_vars, vi++, 0)) != NULL)
     {
-      v2 = nasl_get_var_by_num (&lexic->ctx_vars, vi++, 0);
+      v2 = nasl_get_var_by_num (lexic, &lexic->ctx_vars, vi++, 0);
       if (v2 == NULL)
         {
           nasl_perror (lexic, "make_array: odd number (%d) of argument?\n", 
vi);
@@ -509,7 +509,7 @@
 
   bzero (&myvar, sizeof (myvar));
 
-  for (i = vi = 0; (v = nasl_get_var_by_num (&lexic->ctx_vars, vi, 0)) != NULL;
+  for (i = vi = 0; (v = nasl_get_var_by_num (lexic, &lexic->ctx_vars, vi, 0)) 
!= NULL;
        vi++)
     {
       if (v->var_type == VAR2_ARRAY)
@@ -549,7 +549,7 @@
   anon_nasl_var *v;
   nasl_array *a;
 
-  v = nasl_get_var_by_num (&lexic->ctx_vars, 0, 0);
+  v = nasl_get_var_by_num (lexic, &lexic->ctx_vars, 0, 0);
   if (v == NULL)
     return NULL;
   if (v->var_type != VAR2_ARRAY)
@@ -573,7 +573,7 @@
 
   retc = alloc_tree_cell (0, NULL);
   retc->type = CONST_DATA;
-  u = nasl_get_var_by_num (&lexic->ctx_vars, 0, 0);
+  u = nasl_get_var_by_num (lexic, &lexic->ctx_vars, 0, 0);
 
   if (u == NULL)
     s = "null";

Modified: trunk/openvas-libraries/nasl/nasl_var.c
===================================================================
--- trunk/openvas-libraries/nasl/nasl_var.c     2016-10-14 15:42:24 UTC (rev 
26412)
+++ trunk/openvas-libraries/nasl/nasl_var.c     2016-10-17 11:10:37 UTC (rev 
26413)
@@ -68,14 +68,14 @@
 }
 
 anon_nasl_var *
-nasl_get_var_by_num (nasl_array * a, int num, int create)
+nasl_get_var_by_num (void *ctxt, nasl_array *a, int num, int create)
 {
   anon_nasl_var *v = NULL;
 
   if (num < 0)
     {
       /* TBD: implement a min_index field, just like $[ in Perl */
-      nasl_perror (NULL, "Negative integer index are not supported yet!\n");
+      nasl_perror (ctxt, "Negative integer index are not supported yet!\n");
       return NULL;
     }
 
@@ -280,7 +280,7 @@
       switch (idx->type)
         {
         case CONST_INT:
-          av = nasl_get_var_by_num (&u->v.v_arr, idx->x.i_val,
+          av = nasl_get_var_by_num (ctxt, &u->v.v_arr, idx->x.i_val,
                                     /* avoid dangling pointers */
                                     strcmp (name, "_FCT_ANON_ARGS"));
           return var2cell (av);

Modified: trunk/openvas-libraries/nasl/nasl_var.h
===================================================================
--- trunk/openvas-libraries/nasl/nasl_var.h     2016-10-14 15:42:24 UTC (rev 
26412)
+++ trunk/openvas-libraries/nasl/nasl_var.h     2016-10-17 11:10:37 UTC (rev 
26413)
@@ -87,7 +87,7 @@
 void clear_unnamed_var (anon_nasl_var *);
 const char *var2str (const anon_nasl_var *);
 
-anon_nasl_var *nasl_get_var_by_num (nasl_array *, int, int);
+anon_nasl_var *nasl_get_var_by_num (void *, nasl_array *, int, int);
 
 nasl_iterator nasl_array_iterator (tree_cell *);
 tree_cell *nasl_iterate_array (nasl_iterator *);

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits

Reply via email to