diff --git a/base/src/core/rm_session_component.cc b/base/src/core/rm_session_component.cc index 35c9b9604..6c0054b0f 100644 --- a/base/src/core/rm_session_component.cc +++ b/base/src/core/rm_session_component.cc @@ -359,18 +359,16 @@ Rm_session_component::attach(Dataspace_capability ds_cap, size_t size, Object_pool::Guard dsc(_ds_ep->lookup_and_lock(ds_cap)); if (!dsc) throw Invalid_dataspace(); - if (!size) { + if (!size) size = dsc->size() - offset; - if (dsc->size() <= (size_t)offset) { - PWRN("size is 0"); - throw Invalid_dataspace(); - } - } - /* work with page granularity */ size = align_addr(size, get_page_size_log2()); + /* deny creation of regions larger then the actual dataspace */ + if (dsc->size() < size + offset) + throw Invalid_args(); + /* allocate region for attachment */ void *r = 0; if (use_local_addr) {