* luci/libs: properly handle overflows in luci.ip.add()
This commit is contained in:
parent
e502d88407
commit
a87b197aa8
1 changed files with 3 additions and 1 deletions
|
@ -382,8 +382,10 @@ function cidr.add( self, amount )
|
|||
local add = ( #shorts > 0 ) and table.remove( shorts, #shorts ) or 0
|
||||
if ( data[pos] + add ) > 0xFFFF then
|
||||
data[pos] = ( data[pos] + add ) % 0xFFFF
|
||||
if pos > 2 then
|
||||
if pos > 1 then
|
||||
data[pos-1] = data[pos-1] + ( add - data[pos] )
|
||||
else
|
||||
return nil
|
||||
end
|
||||
else
|
||||
data[pos] = data[pos] + add
|
||||
|
|
Loading…
Reference in a new issue