From 997b0360642d5d9254315ba2e04382857436193d Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Tue, 28 Apr 2026 23:13:02 -0500 Subject: [PATCH] Reject invalid policies --- src/func.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/func.cpp b/src/func.cpp index d857dc4c..4c46d98a 100644 --- a/src/func.cpp +++ b/src/func.cpp @@ -22,10 +22,13 @@ int Func::Base::Action::from_string(const std::string_view policyname_) { - policy = Policies::Action::find(policyname_); - if(!policy) + auto *tmp = Policies::Action::find(policyname_); + + if(not tmp) return -EINVAL; + policy = tmp; + return 0; } @@ -38,10 +41,13 @@ Func::Base::Action::to_string(void) const int Func::Base::Create::from_string(const std::string_view policyname_) { - policy = Policies::Create::find(policyname_); - if(!policy) + auto *tmp = Policies::Create::find(policyname_); + + if(not tmp) return -EINVAL; + policy = tmp; + return 0; } @@ -54,10 +60,13 @@ Func::Base::Create::to_string(void) const int Func::Base::Search::from_string(const std::string_view policyname_) { - policy = Policies::Search::find(policyname_); - if(!policy) + auto *tmp = Policies::Search::find(policyname_); + + if(not tmp) return -EINVAL; + policy = tmp; + return 0; }