1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-12 21:57:23 +03:00

bug 4419: Fix address range allocation. Prevents overflow of used leases

This commit is contained in:
Ruben S. Montero 2016-04-15 13:12:46 +02:00
parent 0ae80a18c9
commit 4c703b1d93

View File

@ -894,6 +894,11 @@ int AddressRange::attr_to_allocated(const string& allocated_s)
used_addr++;
}
if ( used_addr > size )
{
return -1;
}
return 0;
}
@ -944,6 +949,11 @@ int AddressRange::allocate_addr(
VectorAttribute* nic,
const vector<string>& inherit)
{
if ( used_addr >= size )
{
return -1;
}
for ( unsigned int i=0; i<size; i++, next = (next+1)%size )
{
if ( allocated.count(next) == 0 )
@ -1318,7 +1328,7 @@ int AddressRange::reserve_addr(int vid, unsigned int rsize, AddressRange *rar)
for (unsigned int j=0; j<rsize; j++, i++)
{
if ( allocated.count(i) != 0 )
if ( allocated.count(i) != 0 || i >= size )
{
valid = false;
break;