1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-29 10:59:02 +00:00

String concat cleanup grab-bag

Mostly just eliminating concatenation-reassignments by chaining
concatenations, reordering assignments to allow better use of bin.pack,
and using tables to store intermediate results before concatenating
them. Used strbuf as a quick fix in dhcp.lua. Eliminated some unused
string variables in vulns.lua.
This commit is contained in:
dmiller
2015-03-02 14:39:29 +00:00
parent c1b2429efd
commit 03110e7e89
13 changed files with 57 additions and 82 deletions

View File

@@ -8,6 +8,7 @@
local bin = require "bin"
local table = require "table"
local stdnse = require "stdnse"
local strbuf = require "strbuf"
local ipOps = require "ipOps"
local packet = require "packet"
_ENV = stdnse.module("eigrp", stdnse.seeall)
@@ -308,7 +309,8 @@ EIGRP = {
--- Converts the request to a string suitable to be sent over a socket.
-- @return data string containing the complete request to send over the socket
__tostring = function(self)
local data = bin.pack(">C", self.ver) -- Version 2
local data = strbuf.new()
data = data .. bin.pack(">C", self.ver) -- Version 2
data = data .. bin.pack(">C", self.opcode) -- Opcode: Hello
-- If checksum not manually.
@@ -378,6 +380,7 @@ EIGRP = {
stdnse.debug1("eigrp.lua: TLV type %d unknown.", tlv.type)
end
end
data = strbuf.dump(data)
-- In the end, correct the checksum if not manually set
if not self.checksum then
data = data:sub(1,2) .. bin.pack(">S", packet.in_cksum(data)) .. data:sub(5)