Hello All,
I'm noticing weird behavior with substr and am wondering if this is
excepted behavior. Here's an example:
poo.nasl:
stuff = "nessus";
c = display ("Stuff: " + stuff + "\n");
display ("c: " + c + "\n");
newst = substr(stuff,0);
c = display ("Stuff: " + stuff + "\n");
display ("c: " + c + "\n");
c = display ("Newst: " + newst + "\n");
display ("c: " + c + "\n");
c = display ("Stuff: " + stuff + "\n");
display ("c: " + c + "\n");
<output>
> nasl poo.nasl
** WARNING : packet forgery will not work
** as NASL is not running as root
Stuff: nessus
c: 14
Stuff: nessus
c: 14
Newst: nessus\nc: 15
Stuff: nessus
c: 14
>
I would expect ``c = display ("Newst: " + newst + "\n");'' to
properly linefeed the string. It's like there isn't a string
termination in there for display() to see the end of newst, so it
thinks the "\n" is part of the string. It's not until the next
display function is called that the string is terminated.
So, am I missing something or is this expected behavior? How can I
force a termination on newst if this is expected behavior?
TIA,
Jon
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
I'm noticing weird behavior with substr and am wondering if this is
excepted behavior. Here's an example:
poo.nasl:
stuff = "nessus";
c = display ("Stuff: " + stuff + "\n");
display ("c: " + c + "\n");
newst = substr(stuff,0);
c = display ("Stuff: " + stuff + "\n");
display ("c: " + c + "\n");
c = display ("Newst: " + newst + "\n");
display ("c: " + c + "\n");
c = display ("Stuff: " + stuff + "\n");
display ("c: " + c + "\n");
<output>
> nasl poo.nasl
** WARNING : packet forgery will not work
** as NASL is not running as root
Stuff: nessus
c: 14
Stuff: nessus
c: 14
Newst: nessus\nc: 15
Stuff: nessus
c: 14
>
I would expect ``c = display ("Newst: " + newst + "\n");'' to
properly linefeed the string. It's like there isn't a string
termination in there for display() to see the end of newst, so it
thinks the "\n" is part of the string. It's not until the next
display function is called that the string is terminated.
So, am I missing something or is this expected behavior? How can I
force a termination on newst if this is expected behavior?
TIA,
Jon
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005