Mailing List Archive

libnasl/nasl exec.c, 1.84, 1.85 nasl_func.c, 1.19, 1.20 nasl_grammar.y, 1.44, 1.45 nasl_http.c, 1.28, 1.29 nasl_init.c, 1.89, 1.90 nasl_lex_ctxt.h, 1.11, 1.12 nasl_nessusd_glue.c, 1.41, 1.42 nasl_packet_forgery.c, 1.60, 1.61 nasl_socket.c, 1.43, 1.44 nasl
Update of /usr/local/cvs/libnasl/nasl
In directory raccoon.nessus.org:/tmp/cvs-serv3507/libnasl/nasl

Modified Files:
exec.c nasl_func.c nasl_grammar.y nasl_http.c nasl_init.c
nasl_lex_ctxt.h nasl_nessusd_glue.c nasl_packet_forgery.c
nasl_socket.c nasl_socket.h nasl_text_utils.c nasl_var.c
strutils.c strutils.h.in
Log Message:
Synchronize back DEVEL with 2.2

Index: exec.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/exec.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- exec.c 23 Apr 2006 20:38:18 -0000 1.84
+++ exec.c 12 Sep 2006 09:43:23 -0000 1.85
@@ -1450,7 +1450,7 @@
}

if (len2 == 0 || len1 < len2 ||
- (p = (char*)memmem(p1, len1, p2, len2)) == NULL)
+ (p = (char*)nasl_memmem(p1, len1, p2, len2)) == NULL)
{
s3 = emalloc(len1);
memcpy(s3, p1, len1);
@@ -1628,7 +1628,7 @@
}

if(len1 <= len2)
- flag = ((void*)memmem(p2, len2, p1, len1) != NULL);
+ flag = ((void*)nasl_memmem(p2, len2, p1, len1) != NULL);
else
flag = 0;


Index: nasl_func.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_func.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- nasl_func.c 15 Nov 2004 17:37:55 -0000 1.19
+++ nasl_func.c 12 Sep 2006 09:43:23 -0000 1.20
@@ -66,13 +66,6 @@
return NULL;
}

-static int
-stringcompare(const void * a, const void * b)
-{
- char ** s1 = (char**)a, ** s2 = (char**)b;
- return strcmp(*s1, *s2);
-}
-
nasl_func*
insert_nasl_func(lex_ctxt* lexic, const char* fname, tree_cell* decl_node)
{
@@ -103,7 +96,8 @@
if (pc->x.str_val != NULL)
pf->args_names[i ++] = estrdup(pc->x.str_val);
/* sort arg names */
- qsort(pf->args_names, pf->nb_named_args, sizeof(pf->args_names[0]), stringcompare);
+ qsort(pf->args_names, pf->nb_named_args,
+ sizeof(pf->args_names[0]), strcmp);

pf->block = decl_node->link[1];
ref_cell(pf->block);
@@ -145,6 +139,13 @@
return NULL;
}

+static int
+stringcompare(const void * a, const void * b)
+{
+ char ** s1 = (char**)a, ** s2 = (char**)b;
+ return strcmp(*s1, *s2);
+}
+
extern FILE* nasl_trace_fp;

tree_cell*
@@ -187,11 +188,7 @@
else
{
size_t num = f->nb_named_args;
- if (lfind(&pc->x.str_val, f->args_names, &num,
- sizeof(char*), stringcompare) == NULL)
- nasl_perror(lexic, "No such arg '%s' for function '%s' - might be ignored\n",
- pc->x.str_val, f->func_name);
- else
+ if (lfind(&pc->x.str_val, f->args_names, &num, sizeof(char*), stringcompare) != NULL)
nb_n ++;
}


Index: nasl_grammar.y
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_grammar.y,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- nasl_grammar.y 19 Nov 2004 09:06:24 -0000 1.44
+++ nasl_grammar.y 12 Sep 2006 09:43:23 -0000 1.45
@@ -1,3 +1,5 @@
+%pure_parser
+%expect 1
%{
/* Nessus Attack Scripting Language version 2
*
@@ -43,8 +45,6 @@
tree_cell *node;
}

-%pure_parser
-%expect 1

%token IF
%token ELSE
@@ -622,10 +622,14 @@
{
char *p;
naslctxt *ctx = parm;
- FILE *fp = ctx->fp;
+ FILE *fp;
int c, st = ST_START, len, r;
int x, i;

+ if ( parm == NULL )
+ return -1;
+
+ fp = ctx->fp;
p = ctx->buffer;
len = 0;


Index: nasl_http.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_http.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- nasl_http.c 27 Oct 2004 17:06:51 -0000 1.28
+++ nasl_http.c 12 Sep 2006 09:43:23 -0000 1.29
@@ -216,34 +216,6 @@
}


-/*
- * Syntax :
- * http_recv_header(soc)
- */
-tree_cell * nasl_http_recv_headers(lex_ctxt * lexic)
-{
- tree_cell * retc;
- int soc = get_int_var_by_num(lexic, 0, -1);
- char * buf = NULL;
- int sz = 0;
-
- if(soc <= 0)
- {
- nasl_perror(lexic, "http_recv_header(): syntax: http_recv_header(<soc>)\n");
- return NULL;
- }
-
- http_recv_headers(soc, &buf, &sz);
- if ( buf == NULL || sz <= 0 )
- return NULL;
-
- retc = alloc_tree_cell(0, NULL);
- retc->type = CONST_DATA;
- retc->size = sz;
- retc->x.str_val = buf;
- return retc;
-}
-
/*-------------------[ cgibin() ]--------------------------------*/



Index: nasl_init.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_init.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- nasl_init.c 12 Jul 2005 19:07:14 -0000 1.89
+++ nasl_init.c 12 Sep 2006 09:43:23 -0000 1.90
@@ -98,6 +98,7 @@
"open_sock_udp", nasl_open_sock_udp, 1, { NULL },
"open_priv_sock_tcp", nasl_open_priv_sock_tcp, 0, { "dport", "sport", "timeout", NULL },
"open_priv_sock_udp", nasl_open_priv_sock_udp, 0, { "dport", "sport", NULL },
+ "socket_get_error", nasl_socket_get_error, 1, { NULL },

"recv", nasl_recv, 0, { "length", "min", "socket", "timeout", NULL },
"recv_line", nasl_recv_line, 0, { "length", "socket", "timeout", NULL },
@@ -106,9 +107,7 @@
"join_multicast_group", nasl_join_multicast_group, 1, { NULL },
"leave_multicast_group", nasl_leave_multicast_group, 1, { NULL },
"get_source_port", nasl_get_source_port, 1, { NULL }, /* DOC! */
- "get_sock_errno", nasl_get_sock_errno, 1, { NULL }, /* DOC! */
- "errno_conn_reset", nasl_errno_conn_reset, 1, { NULL }, /* DOC! */
-
+
"cgibin", cgibin, 0, { NULL },
"is_cgi_installed", nasl_is_cgi_installed, 1, {"item", "port", NULL },
"http_open_socket", http_open_socket, 1, { NULL },
@@ -118,8 +117,6 @@
"http_delete", http_delete, 0, {"data", "item", "port", NULL },
"http_put", http_put, 0, {"data", "item", "port", NULL },
"http_close_socket", http_close_socket, 0, { "socket", NULL },
- "http_recv_headers", nasl_http_recv_headers, 1, { NULL },
-

"get_host_name", get_hostname, 0, { NULL },
"get_host_ip", get_host_ip, 0, { NULL },
@@ -177,7 +174,6 @@
"localtime", nasl_localtime, 1, { "utc" },
"mktime", nasl_mktime, 0, { "hour", "isdst", "mday", "min", "mon", "sec", "year" },

-
"open_sock_kdc", nasl_open_sock_kdc, 0, { NULL },

"telnet_init", nasl_telnet_init, 1, { NULL },
@@ -338,8 +334,6 @@
"ENCAPS_SSLv2", NESSUS_ENCAPS_SSLv2,
"ENCAPS_SSLv3", NESSUS_ENCAPS_SSLv3,
"ENCAPS_TLSv1", NESSUS_ENCAPS_TLSv1,
- "ENCAPS_TLSv10", NESSUS_ENCAPS_TLSv10,
- "ENCAPS_TLSv11", NESSUS_ENCAPS_TLSv11,

"NASL_LEVEL", NASL_LEVEL,

@@ -369,48 +363,11 @@

"MSG_OOB", MSG_OOB,

-#ifdef EINTR
- "EINTR", EINTR,
-#endif
-#ifdef EBADF
- "EBADF", EBADF,
-#endif
-#ifdef EAGAIN
- "EAGAIN", EAGAIN,
-#endif
-#ifdef ENOMEM
- "ENOMEM", ENOMEM,
-#endif
-#ifdef EACCES
- "EACCES", EACCES,
-#endif
-#ifdef EFAULT
- "EFAULT", EFAULT,
-#endif
-#ifdef EINVAL
- "EINVAL", EINVAL,
-#endif
-#ifdef ENFILE
- "ENFILE", ENFILE,
-#endif
-#ifdef EMFILE
- "EMFILE", EMFILE,
-#endif
-#ifdef ESPIPE
- "ESPIPE", ESPIPE,
-#endif
-#ifdef EPIPE
- "EPIPE", EPIPE,
-#endif
-#ifdef EDOM
- "EDOM", EDOM,
-#endif
-#ifdef ERANGE
- "ERANGE", ERANGE,
-#endif
-#ifdef ECONNRESET
- "ECONNRESET", ECONNRESET,
-#endif
+ "NOERR", NASL_ERR_NOERR,
+ "ETIMEDOUT", NASL_ERR_ETIMEDOUT,
+ "ECONNRESET", NASL_ERR_ECONNRESET,
+ "EUNREACH", NASL_ERR_EUNREACH,
+ "EUNKNOWN", NASL_ERR_EUNKNOWN,

NULL, 0,
};

Index: nasl_lex_ctxt.h
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_lex_ctxt.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- nasl_lex_ctxt.h 18 Feb 2005 14:55:36 -0000 1.11
+++ nasl_lex_ctxt.h 12 Sep 2006 09:43:23 -0000 1.12
@@ -62,7 +62,6 @@

tree_cell *get_variable_by_name(lex_ctxt*, const char*);
tree_cell *get_array_elem(lex_ctxt*, const char* /*array name*/, tree_cell*);
-named_nasl_var* get_var_ref_by_name(lex_ctxt*, const char*, int);
anon_nasl_var* add_numbered_var_to_ctxt(lex_ctxt*, int, tree_cell*);
named_nasl_var* add_named_var_to_ctxt(lex_ctxt*, const char*, tree_cell*);
tree_cell* nasl_read_var_ref(lex_ctxt*, tree_cell*);

Index: nasl_nessusd_glue.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_nessusd_glue.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- nasl_nessusd_glue.c 7 Jul 2005 00:15:42 -0000 1.41
+++ nasl_nessusd_glue.c 12 Sep 2006 09:43:23 -0000 1.42
@@ -511,13 +511,13 @@
value = get_plugin_preference(script_infos, pref);
if(value == NULL)
{
- nasl_perror(lexic, "script_get_preference_file_location: could not get preference '%s'\n", pref);
+ nasl_perror(lexic, "script_get_preference_file_location: could not get preference %s\n", pref);
return NULL;
}
local = get_plugin_preference_fname(script_infos, value);
if(local == NULL)
{
- nasl_perror(lexic, "script_get_preference_file_location: could not get local file name from preference '%s' (value=%s)\n", pref, value);
+ nasl_perror(lexic, "script_get_preference_file_location: could not get local file name from preference %s\n", pref);
return NULL;
}

@@ -739,6 +739,13 @@
if( name == NULL )
{
nasl_perror(lexic, "Syntax error with replace_kb_item() [null name]\n", name);
+ return FAKE_CELL;
+ }
+
+ if (! lexic->authenticated &&
+ strncmp(name, SECRET_KB_PREFIX, sizeof(SECRET_KB_PREFIX) - 1) == 0)
+ {
+ nasl_perror(lexic, "Only signed scripts can set a Secret/ KB entry\n");
return FAKE_CELL;
}


Index: nasl_packet_forgery.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_packet_forgery.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- nasl_packet_forgery.c 12 Jul 2005 19:07:14 -0000 1.60
+++ nasl_packet_forgery.c 12 Sep 2006 09:43:23 -0000 1.61
@@ -25,6 +25,7 @@
#include "nasl_var.h"
#include "nasl_lex_ctxt.h"
#include "exec.h"
+#include "nasl_socket.h"

#include "nasl_debug.h"
#include "capture_packet.h"
@@ -1164,19 +1165,14 @@
int i = 0;
int bpf;
char filter[255];
- struct ip * pk = NULL;
+ u_char * pk = NULL;
tree_cell * retc;
int opt = 1;
+ struct timeval tv;
+ int len;
#define rnd_tcp_port() (rand() % 65535 + 1024)
-
-
-
int sports[]= { 0, 0, 0, 0, 0, 1023, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 20, 0, 25, 0, 0, 0};
int ports[] = { 139, 135, 445, 80, 22, 515, 23, 21, 6000, 1025, 25, 111, 1028, 9100, 1029, 79, 497, 548, 5000, 1917, 53, 161, 9001, 65535, 443, 113, 993, 8080, 0};
-
-
-
-
int num_ports = 0;


@@ -1264,8 +1260,9 @@
soca.sin_family = AF_INET;
soca.sin_addr = ip->ip_dst;
sendto(soc, (const void*)ip, 40, 0, (struct sockaddr *)&soca, sizeof(soca));
- if(bpf >= 0 && (pk = capture_next_packet(bpf, 0, NULL)))flag++;
- i++;
+ tv.tv_sec = 0;
+ tv.tv_usec = 100000;
+ if(bpf >= 0 && (pk = bpf_next_tv(bpf, &len, &tv)))flag++;
}
}

@@ -1307,6 +1304,8 @@
if(setsockopt(soc, IPPROTO_IP, IP_HDRINCL, (char*)&i, sizeof(i))<0)
perror("setsockopt ");
#endif
+
+

while ((ip = get_str_var_by_num(lexic, vi)) != NULL)
{
@@ -1320,9 +1319,9 @@
}

sip = (struct ip *)ip;
-
if( use_pcap != 0 && bpf < 0)
bpf = init_capture_device(sip->ip_dst, sip->ip_src, filter);
+

bzero(&sockaddr, sizeof(struct sockaddr_in));
sockaddr.sin_family = AF_INET;

Index: nasl_socket.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_socket.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- nasl_socket.c 7 Jul 2005 00:15:42 -0000 1.43
+++ nasl_socket.c 12 Sep 2006 09:43:23 -0000 1.44
@@ -30,6 +30,7 @@

/*--------------------------------------------------------------------------*/
#include <includes.h>
+#include "nasl.h"

#include "nasl_tree.h"
#include "nasl_global_ctxt.h"
@@ -232,6 +233,11 @@
else
return NULL;
}
+ else if ( errno != EINPROGRESS )
+ {
+ close(sock);
+ return NULL;
+ }
}

do {
@@ -242,12 +248,11 @@
e = select(sock + 1, NULL, &rd, NULL, to > 0 ? &tv:NULL);
} while ( e < 0 && errno == EINTR );

- if (e == 0) /* timeout */
- {
- /* Should we set /tmp/ConnectTimeout/TCP/<port> ? */
- close(sock);
- return NULL;
- }
+ if ( e <= 0 )
+ {
+ close ( sock );
+ return FAKE_CELL;
+ }

block_socket(sock);
opt_sz = sizeof(opt);
@@ -563,6 +568,7 @@
char * data = get_str_local_var_by_name(lexic, "data");
int option = get_int_local_var_by_name(lexic, "option", 0);
int length = get_int_local_var_by_name(lexic, "length", 0);
+ int data_length = get_var_size_by_name(lexic, "data");
int n;
tree_cell * retc;
int type;
@@ -576,8 +582,8 @@
return NULL;
}

- if( length == 0 )
- length = get_var_size_by_name(lexic, "data");
+ if( length <= 0 || length > data_length )
+ length = data_length;


if(!fd_is_stream(soc) &&
@@ -785,56 +791,48 @@
}


+
tree_cell*
-nasl_get_sock_errno(lex_ctxt* lexic)
+nasl_socket_get_error(lex_ctxt* lexic)
{
- int s, err;
- tree_cell *retc;
+ int soc = get_int_var_by_num(lexic, 0, -1);
+ tree_cell * retc;
+ int err;

- s = get_int_var_by_num(lexic, 0, -1);
- if (s < 0)
- {
- nasl_perror(lexic, "get_sock_errno: missing socket parameter\n");
- return NULL;
- }
- err = get_and_clear_stream_socket_errno(s);
- if (err == -1)
- return NULL;
+ if ( soc < 0 || ! fd_is_stream(soc) )
+ return NULL;

+ err = stream_get_err(soc);
retc = alloc_typed_cell(CONST_INT);
- retc->x.i_val = err;
- return retc;
-}
-
-tree_cell*
-nasl_errno_conn_reset(lex_ctxt* lexic)
-{
- tree_cell *retc = NULL;
- int e, flag = 0, test = 0;
-
- e = get_int_var_by_num(lexic, 0, -1);
- if (e < 0)
- {
- nasl_perror(lexic, "errno_conn_reset: missing error parameter\n");
- return NULL;
- }

+ switch ( err )
+ {
+ case 0 :
+ retc->x.i_val = NASL_ERR_NOERR;
+ break;
+ case ETIMEDOUT:
+ retc->x.i_val = NASL_ERR_ETIMEDOUT;
+ break;
+ case EBADF:
+ case EPIPE:
#ifdef ECONNRESET
- if (e == ECONNRESET)
- flag = 1;
- test ++;
+ case ECONNRESET:
#endif
- /* More tests should be added for other Unix flavours */
+#ifdef ENOTSOCK
+ case ENOTSOCK:
+#endif
+ retc->x.i_val = NASL_ERR_ECONNRESET;
+ break;

- if (test == 0)
- {
- nasl_perror(lexic, "errno_conn_reset is not implemented on this operating system\n");
- return NULL;
- }
+ case ENETUNREACH:
+ case EHOSTUNREACH:
+ retc->x.i_val = NASL_ERR_EUNREACH;
+ break;

- retc = alloc_typed_cell(CONST_INT);
- retc->x.i_val = flag;
- return retc;
-}
+default:
+ fprintf(stderr, "Unknown error %d %s\n", err, strerror(err));
+ }


+ return retc;
+}

Index: nasl_socket.h
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_socket.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- nasl_socket.h 9 Apr 2005 14:07:06 -0000 1.7
+++ nasl_socket.h 12 Sep 2006 09:43:24 -0000 1.8
@@ -44,6 +44,7 @@
tree_cell * nasl_open_sock_udp(lex_ctxt *);
/* private func */
tree_cell * nasl_open_sock_tcp_bufsz(lex_ctxt *, int);
+tree_cell * nasl_socket_get_error(lex_ctxt*);

tree_cell * nasl_open_priv_sock_tcp(lex_ctxt *);
tree_cell * nasl_open_priv_sock_udp(lex_ctxt *);
@@ -59,7 +60,5 @@
tree_cell * nasl_leave_multicast_group(lex_ctxt *);

tree_cell * nasl_get_source_port(lex_ctxt*);
-tree_cell * nasl_get_sock_errno(lex_ctxt*);
-tree_cell * nasl_errno_conn_reset(lex_ctxt*);

#endif

Index: nasl_text_utils.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_text_utils.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- nasl_text_utils.c 21 Jul 2005 17:53:03 -0000 1.50
+++ nasl_text_utils.c 12 Sep 2006 09:43:24 -0000 1.51
@@ -789,7 +789,10 @@
}

if(nasl_regexec(&re, string, (size_t)NS, subs, 0) != 0)
+ {
+ nasl_regfree(&re);
return NULL;
+ }

retc = alloc_tree_cell(0, NULL);
retc->type = DYN_ARRAY;
@@ -827,7 +830,7 @@
#define MAX_INT (~(1 << (sizeof(int) * 8 - 1)))
#endif
i2 = get_int_var_by_num(lexic, 2, MAX_INT);
- if (i2 > sz1) i2 = sz1-1;
+ if (i2 >= sz1) i2 = sz1-1;

if (s1 == NULL || i1 < 0)
{
@@ -876,7 +879,7 @@
return NULL;
}

- if (i1 > sz1)
+ if (i1 >= sz1)
{
nasl_perror(lexic, "insstr: cannot insert string2 after end of string1\n");
return NULL;
@@ -961,7 +964,16 @@

sep = get_str_local_var_by_name(lexic, "sep");
if (sep != NULL)
+ {
sep_len = get_var_size_by_name(lexic, "sep");
+ if ( sep_len <= 0 ) sep_len = strlen(sep);
+ if ( sep_len <= 0 )
+ {
+ nasl_perror(lexic, "split: invalid 'seplen' parameter\n");
+ return NULL;
+ }
+ }
+
keep = get_int_local_var_by_name(lexic, "keep", 1);

retc = alloc_tree_cell(0, NULL);
@@ -976,7 +988,7 @@
i = 0; j = 0;
for(;;)
{
- if ((p = (char*)memmem(str + i, len - i, sep, sep_len)) == NULL)
+ if ((p = (char*)nasl_memmem(str + i, len - i, sep, sep_len)) == NULL)
{
v.v.v_str.s_siz = len - i;
v.v.v_str.s_val = (unsigned char*)str + i;
@@ -1150,7 +1162,7 @@
if(sz_b > sz_a)
return NULL;

- c = (char*)memmem(a, sz_a, b, sz_b);
+ c = (char*)nasl_memmem(a, sz_a, b, sz_b);
if(c == NULL)
return FAKE_CELL;

@@ -1197,7 +1209,7 @@
if ((sz_a == start) || (sz_b > sz_a + start))
return retc;

- c = (char*)memmem(a + start, sz_a - start, b, sz_b);
+ c = (char*)nasl_memmem(a + start, sz_a - start, b, sz_b);
if(c != NULL)
retc->x.i_val = c - a;
return retc;
@@ -1246,9 +1258,9 @@
s = emalloc(1);
sz2 = 0;
n = 0;
- for (i1 = i2 = 0; i1 < sz_a - sz_b; )
+ for (i1 = i2 = 0; i1 <= sz_a - sz_b; )
{
- c = (char*)memmem(a + i1, sz_a - i1, b, sz_b);
+ c = (char*)nasl_memmem(a + i1, sz_a - i1, b, sz_b);
if(c == NULL)
break;
l = (c - a) - i1;

Index: nasl_var.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/nasl_var.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- nasl_var.c 23 Nov 2005 12:29:07 -0000 1.59
+++ nasl_var.c 12 Sep 2006 09:43:24 -0000 1.60
@@ -119,7 +119,7 @@


/* This function climbs up in the context list */
-named_nasl_var*
+static named_nasl_var*
get_var_ref_by_name(lex_ctxt* ctxt, const char* name, int climb)
{
named_nasl_var *v, *prev;
@@ -141,13 +141,8 @@
c->ctx_vars.hash_elt[h] = v;
}
#endif
-#if NASL_DEBUG > 0
- if (c != ctxt /* Not the original context */
- && c->up_ctxt != NULL) /* Not the global context */
- nasl_perror(ctxt, "get_var_ref_by_name: variable %s found in intermediate context. This might be misleading\n", name);
-#endif
- return v;
- }
+ return v;
+ }
#ifdef SILLY_OPT
else
prev = v;
@@ -521,15 +516,12 @@
break;

case VAR2_ARRAY:
- /* TBD: handle arrays here for multi-dimensional arrays */
- nasl_perror(NULL, "copy_anon_var: cannot handle arrays\n");
- clear_anon_var(v1);
+ copy_array(&v1->v.v_arr, &v2->v.v_arr, 0);
break;

default:
nasl_perror(NULL, "copy_anon_var: unhandled type 0x%x\n", v2->var_type);
clear_anon_var(v1);
- break;
}
}

@@ -916,7 +908,7 @@
}
else
{
- a->num_elt = erealloc(a->num_elt, (num+1) * sizeof(anon_nasl_var*));
+ a->num_elt = erealloc(a->num_elt, (num+1) * sizeof(anon_nasl_var));
bzero(a->num_elt + a->max_idx, sizeof(anon_nasl_var*) * (num+1 - a->max_idx));
a->max_idx = num + 1;
}

Index: strutils.c
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/strutils.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- strutils.c 29 Jul 2005 17:46:25 -0000 1.22
+++ strutils.c 12 Sep 2006 09:43:24 -0000 1.23
@@ -54,11 +54,10 @@



-#ifndef HAVE_MEMMEM
/*
* Slow replacement for memmem()
*/
-void * memmem(haystack, hl_len, needle, n_len)
+void * nasl_memmem(haystack, hl_len, needle, n_len)
const void * haystack;
size_t hl_len;
const void * needle;
@@ -68,7 +67,8 @@
char * nd = (char*)needle;
int i;

- if ( hl_len < n_len ) return NULL;
+ if ( hl_len < n_len )
+ return NULL;

for(i=0;i<=hl_len-n_len;i++)
{
@@ -83,6 +83,5 @@
}
return(NULL);
}
-#endif



Index: strutils.h.in
===================================================================
RCS file: /usr/local/cvs/libnasl/nasl/strutils.h.in,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- strutils.h.in 17 May 2004 17:50:37 -0000 1.11
+++ strutils.h.in 12 Sep 2006 09:43:24 -0000 1.12
@@ -29,10 +29,7 @@
*/
#ifndef NASL2_STRUTILS_H__
#define NASL2_STRUTILS_H__
-#undef HAVE_MEMMEM
char* nasl_strndup(char*, int);
int str_match(const char *, const char *, int);
-#ifndef HAVE_MEMMEM
-void * memmem(const void *, size_t, const void *, size_t);
-#endif
+void * nasl_memmem(const void *, size_t, const void *, size_t);
#endif

_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs