mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
bug #1264: Do not allow wrong number in GRAPHICS/PORT; i.e. floats, <0, strings...
This commit is contained in:
parent
45edfadff3
commit
d1b71d0df1
@ -1612,7 +1612,7 @@ private:
|
||||
* Parse the "GRAPHICS" attribute and generates a default PORT if not
|
||||
* defined
|
||||
*/
|
||||
void parse_graphics();
|
||||
int parse_graphics(string& error_str);
|
||||
|
||||
/**
|
||||
* Searches the meaningful attributes and moves them from the user template
|
||||
|
@ -256,9 +256,9 @@ int Host::update_info(Template &tmpl,
|
||||
vector<Attribute*> ds_att;
|
||||
vector<Attribute*> local_ds_att;
|
||||
|
||||
int rc;
|
||||
int vmid;
|
||||
long long val;
|
||||
int rc;
|
||||
int vmid;
|
||||
float val;
|
||||
|
||||
string error_st;
|
||||
|
||||
|
@ -392,7 +392,10 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
||||
goto error_requirements;
|
||||
}
|
||||
|
||||
parse_graphics();
|
||||
if ( parse_graphics(error_str) != 0 )
|
||||
{
|
||||
goto error_graphics;
|
||||
}
|
||||
|
||||
parse_well_known_attributes();
|
||||
|
||||
@ -418,6 +421,9 @@ error_context:
|
||||
error_requirements:
|
||||
goto error_rollback;
|
||||
|
||||
error_graphics:
|
||||
goto error_rollback;
|
||||
|
||||
error_rollback:
|
||||
release_disk_images();
|
||||
|
||||
@ -917,16 +923,14 @@ error_cleanup:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::parse_graphics()
|
||||
int VirtualMachine::parse_graphics(string& error_str)
|
||||
{
|
||||
int num;
|
||||
|
||||
vector<Attribute *> array_graphics;
|
||||
VectorAttribute * graphics;
|
||||
|
||||
vector<Attribute *>::iterator it;
|
||||
|
||||
num = user_obj_template->remove("GRAPHICS", array_graphics);
|
||||
int num = user_obj_template->remove("GRAPHICS", array_graphics);
|
||||
|
||||
for (it=array_graphics.begin(); it != array_graphics.end(); it++)
|
||||
{
|
||||
@ -935,17 +939,20 @@ void VirtualMachine::parse_graphics()
|
||||
|
||||
if ( num == 0 )
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
graphics = dynamic_cast<VectorAttribute * >(array_graphics[0]);
|
||||
|
||||
if ( graphics == 0 )
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
string port = graphics->vector_value("PORT");
|
||||
int port_i;
|
||||
|
||||
int rc = graphics->vector_value("PORT", port_i);
|
||||
|
||||
if ( port.empty() )
|
||||
{
|
||||
@ -966,6 +973,13 @@ void VirtualMachine::parse_graphics()
|
||||
oss << ( base_port + ( oid % (limit - base_port) ));
|
||||
graphics->replace("PORT", oss.str());
|
||||
}
|
||||
else if ( rc == -1 || port_i < 0 )
|
||||
{
|
||||
error_str = "Wrong PORT number in GRAPHICS attribute";
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
Loading…
x
Reference in New Issue
Block a user