diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2008-08-08 13:45:09 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2008-08-08 13:45:09 +0000 |
commit | a87b197aa8082bdd3c440c76f97088b190dd8dd4 (patch) | |
tree | d98307f645d9b3ba2d26dc0f80deb0fd6c916f7c /libs | |
parent | e502d88407b9ad17820f0a155dbce160346ced8c (diff) |
* luci/libs: properly handle overflows in luci.ip.add()
Diffstat (limited to 'libs')
-rw-r--r-- | libs/core/luasrc/ip.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libs/core/luasrc/ip.lua b/libs/core/luasrc/ip.lua index 2fe71297d..761a78110 100644 --- 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 |