From: Gunnar Beutner Date: Sun, 15 Mar 2015 10:24:09 +0000 (+0100) Subject: Don't ignore extraneous arguments for functions X-Git-Tag: v2.3.3~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1756859125530b9ac5cc62eeb89ed714adb6e667;p=icinga2 Don't ignore extraneous arguments for functions fixes #8748 --- diff --git a/lib/base/functionwrapper.hpp b/lib/base/functionwrapper.hpp index d5984550b..da5672be9 100644 --- a/lib/base/functionwrapper.hpp +++ b/lib/base/functionwrapper.hpp @@ -51,6 +51,8 @@ Value FunctionWrapperV(void (*function)(T0), const std::vector& arguments { if (arguments.size() < 1) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); function(static_cast(arguments[0])); @@ -68,6 +70,8 @@ Value FunctionWrapperR(TR (*function)(T0), const std::vector& arguments) { if (arguments.size() < 1) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 1) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); return function(static_cast(arguments[0])); } @@ -83,6 +87,8 @@ Value FunctionWrapperV(void (*function)(T0, T1), const std::vector& argum { if (arguments.size() < 2) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 2) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); function(static_cast(arguments[0]), static_cast(arguments[1])); @@ -101,6 +107,8 @@ Value FunctionWrapperR(TR (*function)(T0, T1), const std::vector& argumen { if (arguments.size() < 2) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 2) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); return function(static_cast(arguments[0]), static_cast(arguments[1])); @@ -117,6 +125,8 @@ Value FunctionWrapperV(void (*function)(T0, T1, T2), const std::vector& a { if (arguments.size() < 3) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 3) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -136,6 +146,8 @@ Value FunctionWrapperR(TR (*function)(T0, T1, T2), const std::vector& arg { if (arguments.size() < 3) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 3) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); return function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -153,6 +165,8 @@ Value FunctionWrapperV(void (*function)(T0, T1, T2, T3), const std::vector 4) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -173,6 +187,8 @@ Value FunctionWrapperR(TR (*function)(T0, T1, T2, T3), const std::vector& { if (arguments.size() < 4) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 4) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); return function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -191,6 +207,8 @@ Value FunctionWrapperV(void (*function)(T0, T1, T2, T3, T4), const std::vector 5) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -212,6 +230,8 @@ Value FunctionWrapperR(TR (*function)(T0, T1, T2, T3, T4), const std::vector 5) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); return function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -231,6 +251,8 @@ Value FunctionWrapperV(void (*function)(T0, T1, T2, T3, T4, T5), const std::vect { if (arguments.size() < 6) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 6) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -253,6 +275,8 @@ Value FunctionWrapperR(TR (*function)(T0, T1, T2, T3, T4, T5), const std::vector { if (arguments.size() < 6) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 6) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); return function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -273,6 +297,8 @@ Value FunctionWrapperV(void (*function)(T0, T1, T2, T3, T4, T5, T6), const std:: { if (arguments.size() < 7) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 7) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -296,6 +322,8 @@ Value FunctionWrapperR(TR (*function)(T0, T1, T2, T3, T4, T5, T6), const std::ve { if (arguments.size() < 7) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 7) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); return function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -317,6 +345,8 @@ Value FunctionWrapperV(void (*function)(T0, T1, T2, T3, T4, T5, T6, T7), const s { if (arguments.size() < 8) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 8) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); function(static_cast(arguments[0]), static_cast(arguments[1]), @@ -341,6 +371,8 @@ Value FunctionWrapperR(TR (*function)(T0, T1, T2, T3, T4, T5, T6, T7), const std { if (arguments.size() < 8) BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function.")); + else if (arguments.size() > 8) + BOOST_THROW_EXCEPTION(std::invalid_argument("Too many arguments for function.")); return function(static_cast(arguments[0]), static_cast(arguments[1]),