aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorAsbjørn Sloth Tønnesen <ast@2e8.dk>2019-07-16 19:29:14 +0000
committerAsbjørn Sloth Tønnesen <ast@2e8.dk>2019-07-16 19:29:14 +0000
commit079c662ce5ab285304b3ee877890065ae864ea0c (patch)
tree948fc4acde1edf619bbfe0d1a1344515c355d8c5 /lua
parenta22e99c79588d6b7d8620ed061925230427e1635 (diff)
downloadlua-inet-079c662ce5ab285304b3ee877890065ae864ea0c.tar.gz
lua-inet-079c662ce5ab285304b3ee877890065ae864ea0c.tar.xz
lua-inet-079c662ce5ab285304b3ee877890065ae864ea0c.zip
inet6: __mul: bugfix, need more tests for edge cases
Signed-off-by: Asbjørn Sloth Tønnesen <ast@2e8.dk>
Diffstat (limited to 'lua')
-rw-r--r--lua/inet/init.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/lua/inet/init.lua b/lua/inet/init.lua
index ef8c5f2..b89515e 100644
--- a/lua/inet/init.lua
+++ b/lua/inet/init.lua
@@ -647,6 +647,7 @@ end
function inet6:__mul(n)
local new = self:clone()
local mask = new.mask
+ if mask == 0 then return nil, 'unable to perform operation' end
local pcs = new.pcs
local netbitoverflow = mask % 16
local netbitremainder = (128-mask) % 16
@@ -662,7 +663,7 @@ function inet6:__mul(n)
local shiftet = lshift(n, netbitremainder)
local high_shift = rshift(shiftet, 16)
local low_shift = band(shiftet, 0xffff)
- --print(p, netbitoverflow, hex(shiftet), hex(high_shift), hex(low_shift))
+ --print(p, netbitoverflow, tohex(shiftet), tohex(high_shift), tohex(low_shift))
if was_negative then
high_shift = -high_shift
low_shift = -low_shift