Nmap Development mailing list archives
Re: [nmap-svn] r31481 - nmap-exp/d33tah/lua-exec-examples/ncat
From: David Fifield <david () bamsoftware com>
Date: Tue, 23 Jul 2013 03:27:19 -0700
On Mon, Jul 22, 2013 at 09:10:45PM +0200, Jacek Wielemborek wrote:
2013/7/22 <commit-mailer () nmap org>:Author: d33tah Date: Mon Jul 22 16:47:03 2013 New Revision: 31481 Log: set binary mode for stdout for --lua-exec-internal under Windows. that prevents Windows from messing with line breaks for httpd.lua. Modified: nmap-exp/d33tah/lua-exec-examples/ncat/ncat_main.c Modified: nmap-exp/d33tah/lua-exec-examples/ncat/ncat_main.c ============================================================================== --- nmap-exp/d33tah/lua-exec-examples/ncat/ncat_main.c (original) +++ nmap-exp/d33tah/lua-exec-examples/ncat/ncat_main.c Mon Jul 22 16:47:03 2013 @@ -500,6 +500,13 @@ forking in POSIX builds, Windows does not have the fork() system call and thus requires this workaround. More info here: http://seclists.org/nmap-dev/2013/q2/492 */ +#ifdef WIN32 + if (o.debug) + logdebug("Enabling binary stdout for the Lua output.\n"); + int result = _setmode(_fileno(stdout), _O_BINARY); + if (result == -1) + perror("Cannot set mode"); +#endif ncat_assert(argc == 3); o.cmdexec = argv[2]; lua_setup();This needs some discussion. I'm not sure it's okay to just change the stdout mode for Lua scripts - it could create a discrepancy between "traditional" Lua behavior on Windows and one altered by binary mode. I just did some testing that proves that without the binary mode, print("a") produces CR LF. With binary mode on, it's just \n.
That change seems right. We already do this _setmode trick for stdout on Windows through the function set_lf_mode. Please make this change in the trunk. David Fifield _______________________________________________ Sent through the dev mailing list http://nmap.org/mailman/listinfo/dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Re: [nmap-svn] r31481 - nmap-exp/d33tah/lua-exec-examples/ncat Jacek Wielemborek (Jul 22)
- Re: [nmap-svn] r31481 - nmap-exp/d33tah/lua-exec-examples/ncat David Fifield (Jul 23)