From a64d85c73d4cb42cae3b404b16ac66b7e0d6fbda Mon Sep 17 00:00:00 2001 From: rewanth Date: Fri, 1 Sep 2017 20:17:07 +0000 Subject: [PATCH] Adds optional offset parameter to msrpctypes.lua --- nselib/msrpctypes.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nselib/msrpctypes.lua b/nselib/msrpctypes.lua index a720ef04e..80e4ff762 100644 --- a/nselib/msrpctypes.lua +++ b/nselib/msrpctypes.lua @@ -4524,14 +4524,17 @@ end --- Unmarshalls a null-terminated Unicode string (LPTSTR datatype) --- @param w_str The data being processed --- @param startpos The current position within the data +-- @param w_str The data being processed +-- @param startpos The current position within the data +-- @param offset [optional] Sets the number of bytes to be skipped from startpos -- @return The new position -- @return The unmarshalled string -function unmarshall_lptstr(w_str, startpos) +function unmarshall_lptstr(w_str, startpos, offset) + + offset = offset or 0 local _ - local endpos = startpos + local endpos = startpos + offset repeat _, endpos = w_str:find("\0\0", endpos, true) @@ -4540,7 +4543,7 @@ function unmarshall_lptstr(w_str, startpos) end until endpos % 2 == 0 - return endpos + 1, w_str:sub(startpos, endpos) + return endpos + 1, w_str:sub(startpos + offset, endpos) end