Jan-Oliver Wagner wrote:
> On Thursday, 22. September 2011, Thomas Reinke wrote:
>> Be careful of one thing, iirc there is a difference between
>>
>> a = "hi\n";
>>
>> and
>>
>> a = string("hi\n");
>>
>> The first, iirc, is a 4 character string nil terminated. The
>> second one is a 3 character string ('h', 'i', newline) nil
>> terminated.
> 
> Isn't 'hi\n' == string("hi\n") ?
> 

Consider the following:

thomas@dev:~/ovas/openvas-libraries-3.1.0/nasl$ cat ~/string.nasl
display("Single quoted constant:\n");
a = 'hi\n';
display(a);
display("[", strlen(a), "]\n");
display("Double quoted constant:\n");
a = "hi\n";
display(a);
display("[", strlen(a), "]\n");
display("Single quoted string():\n");
a = string('hi\n');
display(a);
display("[", strlen(a), "]\n");
display("Double quoted string():\n");
a = string("hi\n");
display(a);
display("[", strlen(a), "]\n");


thomas@dev:~/ovas/openvas-libraries-3.1.0/nasl$ ./openvas-nasl -X
~/string.nasl
** WARNING : packet forgery will not work
** as NASL is not running as root
Single quoted constant:
hi
[3]
Double quoted constant:
hi
[4]                      <------------------------- Watch out! -----
Single quoted string():
hi
[3]
Double quoted string():
hi
[3]

So it looks like 'hi\n' == string("hi\n") from what I can tell, but
"hi\n" != string("hi\n")

Thomas.

P.S. ./openvas-nasl help functions appear wrong with the -X option -
notation is reversed.  Run with -X to run in unauthenticated mode
(I think) - but I may be missing something else here.


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

Reply via email to