diff options
Diffstat (limited to 'qpid/cpp')
| -rwxr-xr-x | qpid/cpp/rubygen/framing.0-10/structs.rb | 25 | ||||
| -rw-r--r-- | qpid/cpp/src/tests/MessagingSessionTests.cpp | 7 |
2 files changed, 29 insertions, 3 deletions
diff --git a/qpid/cpp/rubygen/framing.0-10/structs.rb b/qpid/cpp/rubygen/framing.0-10/structs.rb index 0a1bb475c9..f93742e57e 100755 --- a/qpid/cpp/rubygen/framing.0-10/structs.rb +++ b/qpid/cpp/rubygen/framing.0-10/structs.rb @@ -185,6 +185,13 @@ class StructGen < CppGen end end + def check_field(f) + if (size = StringSizeMap[f.cpptype.encoded] and size < 4) + limit = 2 ** (size * 8) + genl "if (#{f.cppname}.size() >= #{limit}) throw IllegalArgumentException(\"Value for #{f.cppname} is too large\");" + end + end + def process_packed_fields(s) s.fields.each { |f| yield f, s.fields.index(f) } end @@ -260,11 +267,16 @@ EOS indent { process_packed_fields(s) { |f, i| genl "set#{f.name.caps}(_#{f.cppname});" if f.type_ == "bit"} process_packed_fields(s) { |f, i| genl "flags |= #{flag_mask(s, i)};" unless f.type_ == "bit"} + s.fields.each { |f| check_field(f) } } genl "}" else indent { gen s.fields.collect { |f| " #{f.cppname}(_#{f.cppname})" }.join(",\n") } - genl "{}" + genl "{" + indent { + s.fields.each { |f| check_field(f) } + } + genl "}" end end #default constructors: @@ -298,6 +310,7 @@ EOS indent { genl "#{f.cppname} = _#{f.cppname};" genl "flags |= #{flag_mask(s, i)};" + check_field(f) } genl "}" genl "#{f.cpptype.ret} #{s.cppname}::get#{f.name.caps}() const { return #{f.cppname}; }" @@ -329,6 +342,7 @@ EOS indent { genl "#{f.cppname} = _#{f.cppname};" genl "flags |= #{flag_mask(s, i)};" + check_field(f) } genl "}" genl "#{f.cpptype.ret} #{s.body_name}::get#{f.name.caps}() const { return #{f.cppname}; }" @@ -364,7 +378,12 @@ EOS end def define_accessors(f) - genl "void set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) { #{f.cppname} = _#{f.cppname}; }" + genl "void set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {" + indent { + genl "#{f.cppname} = _#{f.cppname};" + check_field(f) + } + genl "}" genl "#{f.cpptype.ret} get#{f.name.caps}() const { return #{f.cppname}; }" if (f.cpptype.name == "FieldTable") genl "#{f.cpptype.name}& get#{f.name.caps}() { return #{f.cppname}; }" @@ -401,6 +420,7 @@ EOS #include <ostream> #include "qpid/framing/amqp_types_full.h" +#include "qpid/framing/reply_exceptions.h" #include "qpid/CommonImportExport.h" namespace qpid { @@ -466,7 +486,6 @@ EOS gen <<EOS #include "qpid/framing/#{classname}.h" #include "qpid/framing/Buffer.h" -#include "qpid/framing/reply_exceptions.h" using namespace qpid::framing; diff --git a/qpid/cpp/src/tests/MessagingSessionTests.cpp b/qpid/cpp/src/tests/MessagingSessionTests.cpp index 313e8b3132..968d55fd45 100644 --- a/qpid/cpp/src/tests/MessagingSessionTests.cpp +++ b/qpid/cpp/src/tests/MessagingSessionTests.cpp @@ -1139,6 +1139,13 @@ QPID_AUTO_TEST_CASE(testHeadersExchange) } } +QPID_AUTO_TEST_CASE(testLargeRoutingKey) +{ + MessagingFixture fix; + std::string address = "amq.direct/" + std::string(300, 'x');//routing/binding key can be at most 225 chars in 0-10 + BOOST_CHECK_THROW(fix.session.createReceiver(address), qpid::messaging::MessagingException); +} + QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests |
