This is an automated email from the ASF dual-hosted git repository. chug pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push: new 7b90fab DISPATCH-1249: annotation parser fails to parse single character strings 7b90fab is described below commit 7b90fab6e2ccd596724a01b0069d128d344727af Author: Chuck Rolke <c...@apache.org> AuthorDate: Tue Jan 29 17:04:40 2019 -0500 DISPATCH-1249: annotation parser fails to parse single character strings * Include enough bytes in the parse to find the string * Add a self test that exposes the issue This error manifests itself when router network will not forward a message to an address that consists of a single character. --- src/parse.c | 6 ++--- tests/system_tests_two_routers.py | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/parse.c b/src/parse.c index 3ab33dc..0358590 100644 --- a/src/parse.c +++ b/src/parse.c @@ -46,7 +46,7 @@ ALLOC_DECLARE(qd_parsed_turbo_t); ALLOC_DEFINE(qd_parsed_turbo_t); /** - * size = the number of bytes following the tag + * size = the number of bytes following tag:size (payload, including the count) * count = the number of elements. Applies only to compound structures */ static char *get_type_info(qd_iterator_t *iter, uint8_t *tag, uint32_t *size, uint32_t *count, uint32_t *length_of_size, uint32_t *length_of_count) @@ -723,7 +723,7 @@ const char *qd_parse_annotations_v1( qd_iterator_t *key_iter = qd_iterator_buffer(anno->bufptr.buffer, anno->bufptr.cursor - qd_buffer_base(anno->bufptr.buffer), - anno->size, + anno->size + anno->length_of_size, ITER_VIEW_ALL); assert(key_iter); @@ -739,7 +739,7 @@ const char *qd_parse_annotations_v1( qd_iterator_t *val_iter = qd_iterator_buffer(anno_val->bufptr.buffer, anno_val->bufptr.cursor - qd_buffer_base(anno_val->bufptr.buffer), - anno_val->size, + anno_val->size + anno_val->length_of_size, ITER_VIEW_ALL); assert(val_iter); diff --git a/tests/system_tests_two_routers.py b/tests/system_tests_two_routers.py index 778b40f..550687c 100644 --- a/tests/system_tests_two_routers.py +++ b/tests/system_tests_two_routers.py @@ -262,6 +262,11 @@ class TwoRouterTest(TestCase): test.run() self.assertEqual(None, test.error) + def test_18_single_char_dest_test(self): + test = SingleCharacterDestinationTest(self.routers[0].addresses[0], self.routers[1].addresses[0]) + test.run() + self.assertEqual(None, test.error) + class Timeout(object): def __init__(self, parent): @@ -271,6 +276,55 @@ class Timeout(object): self.parent.timeout() +class SingleCharacterDestinationTest(MessagingHandler): + def __init__(self, address1, address2): + super(SingleCharacterDestinationTest, self).__init__() + self.address1 = address1 + self.address2 = address2 + self.dest = "x" + self.error = None + self.conn1 = None + self.conn2 = None + self.count = 1 + self.n_sent = 0 + self.timer = None + self.sender = None + self.receiver = None + self.n_received = 0 + self.body = "xyz" + + def check_if_done(self): + if self.n_received == self.count: + self.timer.cancel() + self.conn1.close() + self.conn2.close() + + def timeout(self): + self.error = "Timeout Expired: sent=%d, received=%d" % (self.n_sent, self.n_received) + self.conn1.close() + self.conn2.close() + + def on_start(self, event): + self.timer = event.reactor.schedule(TIMEOUT, Timeout(self)) + self.conn1 = event.container.connect(self.address1) + self.conn2 = event.container.connect(self.address2) + self.sender = event.container.create_sender(self.conn1, self.dest) + self.receiver = event.container.create_receiver(self.conn2, self.dest) + + def on_sendable(self, event): + if self.n_sent < self.count: + msg = Message(body=self.body) + event.sender.send(msg) + self.n_sent += 1 + + def on_message(self, event): + self.n_received += 1 + self.check_if_done() + + def run(self): + Container(self).run() + + class LargeMessageStreamTest(MessagingHandler): def __init__(self, address1, address2): super(LargeMessageStreamTest, self).__init__() --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org