You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2020/08/11 16:17:31 UTC

[qpid-dispatch] 02/02: DISPATCH-1742 - Handle zero-length body sections. Fixed a bug in body content length calculation.

This is an automated email from the ASF dual-hosted git repository.

tross pushed a commit to branch dev-protocol-adaptors
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git

commit 713fdfef047c3a94cb69ab7d357ff99948d57589
Author: Ted Ross <tr...@apache.org>
AuthorDate: Tue Aug 11 12:16:08 2020 -0400

    DISPATCH-1742 - Handle zero-length body sections.  Fixed a bug in body content length calculation.
---
 src/message.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/message.c b/src/message.c
index 69312f3..4c5cd9c 100644
--- a/src/message.c
+++ b/src/message.c
@@ -2331,17 +2331,21 @@ void trim_body_data_headers(qd_message_body_data_t *body_data)
     assert(good);
     if (good) {
         unsigned char tag = 0;
+        size_t        vbin_hdr_len = 1;
         next_octet(&cursor, &buffer, &tag);
-        if (tag == QD_AMQP_VBIN8)
+        if (tag == QD_AMQP_VBIN8) {
             advance(&cursor, &buffer, 1);
-        else if (tag == QD_AMQP_VBIN32)
+            vbin_hdr_len += 1;
+        } else if (tag == QD_AMQP_VBIN32) {
             advance(&cursor, &buffer, 4);
+            vbin_hdr_len += 4;
+        }
 
         can_advance(&cursor, &buffer); // bump cursor to the next buffer if necessary
 
         body_data->payload.buffer     = buffer;
         body_data->payload.offset     = cursor - qd_buffer_base(buffer);
-        body_data->payload.length     = location->length;
+        body_data->payload.length     = location->length - vbin_hdr_len;
         body_data->payload.hdr_length = 0;
         body_data->payload.parsed     = true;
         body_data->payload.tag        = tag;
@@ -2372,6 +2376,9 @@ qd_iterator_t *qd_message_body_data_iterator(const qd_message_body_data_t *body_
  */
 int qd_message_body_data_buffer_count(const qd_message_body_data_t *body_data)
 {
+    if (body_data->payload.length == 0)
+        return 0;
+
     int count = 1;
     qd_buffer_t *buffer = body_data->payload.buffer;
     while (!!buffer && buffer != body_data->last_buffer) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org