From dd33291d31740cdf20e7f1404f09b7c265affb04 Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 14 Sep 2026 17:42:01 +0000 Subject: [PATCH] Fix DRDA Parameter parsing in error case --- nselib/drda.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nselib/drda.lua b/nselib/drda.lua index 9ef74a0f3..a97337b02 100644 --- a/nselib/drda.lua +++ b/nselib/drda.lua @@ -268,13 +268,16 @@ DRDA = { status, data = db2socket:receive_buf( match.numbytes(ddm.Length - 10), true ) if ( not(status) ) then - return false, ("Failed to read the remaining %d bytes of the DRDA message") + return false, ("Failed to read the remaining %d bytes of the DRDA message"):format(ddm.Length - 10) end -- add parameters until pos reaches the "end" repeat local param = DRDAParameter:new() pos = param:fromString( data, pos ) + if pos < 1 then + return false, "Bad DRDA Parameter" + end self:addParameter( param ) until ( #data <= pos ) @@ -320,7 +323,7 @@ DRDAParameter = { end self.Length, self.CodePoint, pos = string.unpack( ">I2I2", data, pos ) - if ( self.Length > 0 ) then + if ( self.Length > 4 ) then self.Data, pos = string.unpack("c" .. self.Length - 4, data, pos ) end return pos