Nmap Development mailing list archives

Re: "\r\r" in script output


From: David Fifield <david () bamsoftware com>
Date: Fri, 12 Sep 2008 15:56:24 -0600

On Mon, Sep 08, 2008 at 01:35:47PM -0600, David Fifield wrote:
On Sun, Sep 07, 2008 at 02:18:33AM -0600, David Fifield wrote:
On Sat, Sep 06, 2008 at 01:30:19PM -0700, Fyodor wrote:
I'm happy to report that David's setup.py fix allowed me to create a
working Nmap Windows installer.  I tested Zenmap, and it worked
against scanme.nmap.org.  But then I tried against a machine on my
locan network and it crashed :(.  Here is the command:

nmap -T Aggressive -A flog.yuma.net

Zenmap reported:

--
"Gtk-ERROR **: Char offset 64 is off the end of the line
aborting...
[OK]
--

We figured this bug out eventually. It had to do with Zenmap breaking
lines differently than PyGTK was in the syntax highlighting module.

The bug was uncovered because some script output has \r\r sequences in
it. (PyGTK was breaking lines between each \r, and Zenmap wasn't.) We
fixed the bug but the question arises: Where are the \r\r sequences
coming from?

It might be in this code in formatScriptOutput in output.cc:

#ifdef WIN32
        const char* sep = "\r\n";
#else
        const char* sep = "\n";
#endif
        std::string line_prfx = "|  ";

        char* token = strtok(c_output, sep);

        result += line_prfx + sr.get_id() + ": ";

        while(token != NULL) {
                if(line > 0)
                        result += line_prfx;
                result += std::string(token) + sep;
                token = strtok(NULL, sep);
                line++;
        }

On Windows that's appending "\r\n" to the end of every line of script
output. But I think Windows automatically converts "\n" to "\r\n" for
text streams (such as stdout), so perhaps it's becoming "\r\r\n".

That was the problem, and I fixed it by removing the WIN32 conditional
and just using "\n" everywhere.

David Fifield

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: