From f5a142b0d48f1cecab3fadc6856068d1a74b7048 Mon Sep 17 00:00:00 2001 From: d33tah Date: Tue, 23 Jul 2013 12:36:09 +0000 Subject: [PATCH] make --lua-exec-internal switch STDOUT to binary mode. (this was merged from nmap-exp/d33tah/lua-exec-examples/ncat, r31481) --- ncat/ncat_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ncat/ncat_main.c b/ncat/ncat_main.c index 6c1ccc268..56dcf6d85 100644 --- a/ncat/ncat_main.c +++ b/ncat/ncat_main.c @@ -500,6 +500,13 @@ int main(int argc, char *argv[]) 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();