void UserNSConfig::assertMapCorrect(const IDMap &map, const std::string &ID, unsigned contID, unsigned hostID, unsigned num) const { if (map.size() >= 5) { const std::string msg = "Max number of 5 " + ID + " mappings has been already reached"; LOGE(msg); throw ConfigureException(msg); } uid_t max = (uid_t)-1; if ((contID > (max - num)) || (hostID > (max - num))) { const std::string msg = "Given " + ID + " range exceeds maximum allowed values"; LOGE(msg); throw ConfigureException(msg); } if (map.size()) { for (auto &it : map) { unsigned size = std::get<2>(it); uid_t contMin = std::get<0>(it); uid_t contMax = contMin + size - 1; uid_t hostMin = std::get<1>(it); uid_t hostMax = hostMin + size - 1; if ((contMin <= contID && contID <= contMax) || (hostMin <= hostID && hostID <= hostMax)) { const std::string msg = "Given " + ID + " range overlaps with already configured mappings"; LOGE(msg); throw ConfigureException(msg); } } } }