mirror of
https://github.com/nmap/nmap.git
synced 2026-11-20 08:40:36 +08:00
Compare buffer addresses modulo buffer size
This commit is contained in:
+8
-3
@@ -365,7 +365,11 @@ Telnet = {
|
||||
end,
|
||||
|
||||
DEC_BUF_ADDR = function ( self, addr )
|
||||
return ((addr + 1) % (self.COLS * self.ROWS))
|
||||
return ((addr - 1) % (self.COLS * self.ROWS))
|
||||
end,
|
||||
|
||||
BA_EQU = function ( self, a, b )
|
||||
return (a - b) % (self.COLS * self.ROWS) == 0
|
||||
end,
|
||||
|
||||
--- Initiates tn3270 connection
|
||||
@@ -924,6 +928,7 @@ Telnet = {
|
||||
-- There's all kinds of weird GE stuff we could do, but not now. Maybe in future vers
|
||||
stdnse.debug(4,"Repeat to Address (RA) 0x3C")
|
||||
local ra_baddr = self.DECODE_BADDR(data:byte(i+1), data:byte(i+2))
|
||||
ra_baddr = self:INC_BUF_ADDR(ra_baddr - 1)
|
||||
stdnse.debug(4,"Repeat Character: %s", stdnse.tohex(data:sub(i+1,i+2)))
|
||||
|
||||
stdnse.debug(4,"Repeat to this Address: %s", ra_baddr)
|
||||
@@ -933,7 +938,7 @@ Telnet = {
|
||||
i = i + 3
|
||||
local char_to_repeat = data:sub(i,i)
|
||||
stdnse.debug(4,"Repeat Character: %s", stdnse.tohex(char_to_repeat))
|
||||
while (self.buffer_address ~= ra_baddr) do
|
||||
while not self:BA_EQU(self.buffer_address, ra_baddr) do
|
||||
self:write_char(char_to_repeat)
|
||||
self.buffer_address = self:INC_BUF_ADDR(self.buffer_address)
|
||||
end
|
||||
@@ -943,7 +948,7 @@ Telnet = {
|
||||
i = i + 3
|
||||
stdnse.debug(4,"EAU to this Address: %s", eua_baddr)
|
||||
stdnse.debug(4,"Current Address: %s", self.buffer_address)
|
||||
while (self.buffer_address ~= eua_baddr) do
|
||||
while not self:BA_EQU(self.buffer_address, eua_baddr) do
|
||||
-- do nothing for now. this feature isn't supported/required at the moment
|
||||
self.buffer_address = self:INC_BUF_ADDR(self.buffer_address)
|
||||
--stdnse.debug(3,"Current Address: %s", self.buffer_address)
|
||||
|
||||
Reference in New Issue
Block a user