Made length checks more robusts + bumped sizes, fixes #496

This commit is contained in:
emeric
2024-07-28 11:24:18 +02:00
parent 9bca05fb51
commit b3807f6a53
12 changed files with 151 additions and 30 deletions
+7 -1
View File
@@ -217,8 +217,11 @@ namespace lms::db
} // namespace
ReleaseType::ReleaseType(std::string_view name)
: _name{ std::string(name, 0, _maxNameLength) }
: _name{ name }
{
// As we use the name to uniquely identoify release type, we must throw (and not truncate)
if (name.size() > _maxNameLength)
throw Exception{ "ReleaseType name is too long: " + std::string{ name } + "'" };
}
ReleaseType::pointer ReleaseType::create(Session& session, std::string_view name)
@@ -237,6 +240,9 @@ namespace lms::db
{
session.checkReadTransaction();
if (name.size() > _maxNameLength)
throw Exception{ "Requeted ReleaseType name is too long: " + std::string{ name } + "'" };
return utils::fetchQuerySingleResult(session.getDboSession()->query<Wt::Dbo::ptr<ReleaseType>>("SELECT r_t from release_type r_t").where("r_t.name = ?").bind(name));
}