projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e502d88
)
* luci/libs: properly handle overflows in luci.ip.add()
author
Jo-Philipp Wich
<jow@openwrt.org>
Fri, 8 Aug 2008 13:45:09 +0000
(13:45 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Fri, 8 Aug 2008 13:45:09 +0000
(13:45 +0000)
libs/core/luasrc/ip.lua
patch
|
blob
|
history
diff --git
a/libs/core/luasrc/ip.lua
b/libs/core/luasrc/ip.lua
index 2fe71297d9bcc6c5acc17f040faa95e2bbff28c0..761a7811005288c56c4437496fbc0f63eb877349 100644
(file)
--- a/
libs/core/luasrc/ip.lua
+++ b/
libs/core/luasrc/ip.lua
@@
-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