From d9d47eb93da991e4b8770f17b2714bac8d65b11d Mon Sep 17 00:00:00 2001 From: david Date: Wed, 29 Dec 2010 22:44:03 +0000 Subject: [PATCH] Use sock:receive when neither the "lines" nor "bytes" option is given to comm.exchange. Previously it was acting as if it got bytes=1, which could return as few as one bytes. sock:receive will read until timeout or EOF. --- nselib/comm.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nselib/comm.lua b/nselib/comm.lua index 67caaf23a..8f594907a 100644 --- a/nselib/comm.lua +++ b/nselib/comm.lua @@ -52,11 +52,6 @@ local setup_connect = function(host, port, opts) return status, err end - -- If nothing is given, specify bytes=1 so NSE reads everything - if not opts.lines and not opts.bytes then - opts.bytes = 1 - end - return true, sock end @@ -68,7 +63,12 @@ local read = function(sock, opts) return status, response end - status, response = sock:receive_bytes(opts.bytes) + if opts.bytes then + status, response = sock:receive_bytes(opts.bytes) + return status, response + end + + status, response = sock:receive() return status, response end