diff --git a/CHANGELOG b/CHANGELOG index e6c68dad5..d268b60c6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -52,6 +52,9 @@ o [Windows] Add support for the new loopback behavior in Npcap 0.9983. This o [NSE][GH#2063] IPP request object conversion to string was not working correctly [nnposter] +o [NSE][GH#2063] IPP response parser was not correctly processing + end-of-attributes-tag [nnposter] + o [NSE][GH#2010] Oracle TNS parser was incorrectly unmarshalling DALC byte arrays [nnposter] diff --git a/nselib/ipp.lua b/nselib/ipp.lua index 2bf83a64a..d3a7be274 100644 --- a/nselib/ipp.lua +++ b/nselib/ipp.lua @@ -80,7 +80,6 @@ IPP = { local attrib = IPP.Attribute:new() local val attrib.tag, attrib.name, val, pos = string.unpack(">Bs2s2", data, pos) - -- print(attrib.name, stdnse.tohex(val)) attrib.value = {} table.insert(attrib.value, { tag = attrib.tag, val = val }) @@ -245,35 +244,34 @@ IPP = { resp.version, resp.status, resp.reqid, pos = string.unpack(">I2I2I4", data) resp.attrib_groups = {} - local group + local group = nil repeat - local tag, attrib - tag, pos = string.unpack(">B", data, pos) + local tag = data:byte(pos, pos) if ( tag == IPP.Attribute.IPP_TAG_OPERATION or tag == IPP.Attribute.IPP_TAG_JOB or tag == IPP.Attribute.IPP_TAG_PRINTER or tag == IPP.Attribute.IPP_TAG_END ) then - if ( group ) then + if group then table.insert(resp.attrib_groups, group) + end + if tag ~= IPP.Attribute.IPP_TAG_END then group = IPP.AttributeGroup:new(tag) else - group = IPP.AttributeGroup:new(tag) + group = nil end + pos = pos + 1 else - pos = pos - 1 + if not group then + stdnse.debug2("Unexpected tag: %d", tag) + return + end + local attrib + pos, attrib = IPP.Attribute.parse(data, pos) + group:addAttribute(attrib) end - - if ( not(group) ) then - stdnse.debug2("Unexpected tag: %d", tag) - return - end - - pos, attrib = IPP.Attribute.parse(data, pos) - group:addAttribute(attrib) - - until( pos == #data + 1) + until pos > #data return resp end,