From 005167d25bb76890c930bee3e9fe30ec00f69915 Mon Sep 17 00:00:00 2001 From: rewanth Date: Fri, 1 Sep 2017 04:45:43 +0000 Subject: [PATCH] Adds unmarshall_lptstr function to msrpctypes.lua. Closes #991. --- nselib/msrpctypes.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nselib/msrpctypes.lua b/nselib/msrpctypes.lua index 2ae2f64d3..a720ef04e 100644 --- a/nselib/msrpctypes.lua +++ b/nselib/msrpctypes.lua @@ -4523,6 +4523,26 @@ function unmarshall_SERVICE_STATUS(data, pos) end +--- Unmarshalls a null-terminated Unicode string (LPTSTR datatype) +-- @param w_str The data being processed +-- @param startpos The current position within the data +-- @return The new position +-- @return The unmarshalled string +function unmarshall_lptstr(w_str, startpos) + + local _ + local endpos = startpos + + repeat + _, endpos = w_str:find("\0\0", endpos, true) + if not endpos then + return + end + until endpos % 2 == 0 + + return endpos + 1, w_str:sub(startpos, endpos) + +end local atsvc_DaysOfMonth = {