From b0fddde9d70ffd1e5a5716cf26a9033cb64b9be2 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 4 May 2018 05:10:53 +0000 Subject: [PATCH] Fix return values from calc_torrent_size; was always returning nil --- nselib/bittorrent.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nselib/bittorrent.lua b/nselib/bittorrent.lua index d57ae02e8..7f217542e 100644 --- a/nselib/bittorrent.lua +++ b/nselib/bittorrent.lua @@ -818,10 +818,10 @@ Torrent = calc_torrent_size = function(self) local tor = self.tor_struct local size = nil - if tor[1].type ~= "dict" then return nil end + if tor[1].type ~= "dict" then return nil, "first element not a dict" end for _, m in ipairs(tor[1]) do if m.key == "info" then - if m.value.type ~= "dict" then return nil end + if m.value.type ~= "dict" then return nil, "info is not a dict" end for _, n in ipairs(m.value) do if n.key == "files" then size = 0 @@ -842,7 +842,8 @@ Torrent = end end self.size=size - if size == 0 then return false end + if size == 0 then return false, "size is zero" end + return true end, --- Calculates the info hash using self.info_buf.