Bug 1308695 - uint16 message properties decoded as uint8 [rhel-7]
Summary: uint16 message properties decoded as uint8 [rhel-7]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: qpid-cpp
Version: 3.2
Hardware: All
OS: Linux
urgent
high
Target Milestone: 3.2.1
: ---
Assignee: messaging-bugs
QA Contact: Zdenek Kraus
URL:
Whiteboard:
Depends On: 1301359
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-15 19:06 UTC by Mike Cressman
Modified: 2019-10-10 11:12 UTC (History)
10 users (show)

Fixed In Version: qpid-cpp-0.34-6.el7
Doc Type: Bug Fix
Doc Text:
It was found that any message property declared as an unsigned 16 bit integer would get converted to an unsigned 8 bit value in the broker. If the value was greater than 255, an error would occur in the conversion. The codebase has been updated to ensure the conversion performs as expected and unsigned 16 bit integer values in the message header are now correctly maintained in the broker.
Clone Of: 1301359
Environment:
Last Closed: 2016-03-14 14:53:29 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Apache JIRA QPID-7020 0 None None None 2016-02-15 19:06:16 UTC
Red Hat Product Errata RHBA-2016:0444 0 normal SHIPPED_LIVE Red Hat Enterprise MRG Messaging 3.2.1 Bug Fix Release 2016-03-14 18:52:45 UTC

Description Mike Cressman 2016-02-15 19:06:17 UTC
+++ This bug was initially created as a clone of Bug #1301359 +++

Description of problem:
MessageTransfer::processProperties has trivial typo in decoding uin16 message property type as uint8 variant:

void MessageTransfer::processProperties(qpid::amqp::MapHandler& handler) const
{
..
            switch (v.getType()) {
            case qpid::types::VAR_VOID:
                handler.handleVoid(key); break;
            case qpid::types::VAR_BOOL:
                handler.handleBool(key, v); break;
            case qpid::types::VAR_UINT8:
                handler.handleUint8(key, v); break;
            case qpid::types::VAR_UINT16:
                handler.handleUint8(key, v); break;
..

See the latest line.

Any attempt to call that line raises error:

invalid conversion: Cannot convert from uint16 to uint8 (/builddir/build/BUILD/qpid-cpp-0.34/src/qpid/types/Variant.cpp:280)

One reproducer provided below.


Version-Release number of selected component (if applicable):
qpid-cpp-server-0.34-5.el6.x86_64


How reproducible:
100%

Steps to Reproduce:
1. Have this trivial program that creates queue message_queue, subscribes to the queue, bind to amq.match with x-match:any,number:10809 matcher rule:

$ cat send_uint16_t.cpp 

#include <qpid/messaging/Connection.h>
#include <qpid/messaging/Message.h>
#include <qpid/messaging/Receiver.h>
#include <qpid/messaging/Sender.h>
#include <qpid/messaging/Session.h>

#include <cstdlib>
#include <iostream>

#include <sstream>

using namespace qpid::messaging;
using namespace qpid::types;

using std::stringstream;
using std::string;

int main(int argc, char** argv) {
    const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672";
    
    Connection connection(url, "");
    try {
        connection.open();
        Session session = connection.createSession();
        Receiver receiver = session.createReceiver("message_queue; {create: always, node:{type:queue, durable:false, x-bindings:[{exchange:'amq.match', queue:'message_queue', key:'key', arguments:{x-match:any,number:10809}}]}}");
        Sender sender = session.createSender("amq.match/key");
        Message msg("Some content");
        uint16_t number=10809;
        msg.setProperty("number", number);
        sender.send(msg);
        Message msg2 = receiver.fetch();
        std::cout << "Properties: " << msg2.getProperties() << std::endl
                  << "Content: " << msg.getContent() << std::endl;
        session.close();
        connection.close();
        return 0;
    } catch(const std::exception& error) {
        std::cout << error.what() << std::endl;
        connection.close();
    }
    return 1;   
}

2. Compile it and run against a broker:
g++ -Wall -lqpidclient -lqpidcommon -lqpidmessaging -lqpidtypes send_uint16_t.cpp -o send_uint16_t
./send_uint16_t

3. Check output and also qpid logs


Actual results:
output:
2016-01-24 13:46:30 [Client] warning Broker closed connection: 501, invalid conversion: Cannot convert from uint16 to uint8 (/builddir/build/BUILD/qpid-cpp-0.34/src/qpid/types/Variant.cpp:280)
framing-error: invalid conversion: Cannot convert from uint16 to uint8 (/builddir/build/BUILD/qpid-cpp-0.34/src/qpid/types/Variant.cpp:280)

qpid error:
2016-01-24 13:46:30 [Broker] error Connection exception: framing-error: invalid conversion: Cannot convert from uint16 to uint8 (/builddir/build/BUILD/qpid-cpp-0.34/src/qpid/types/Variant.cpp:280)
2016-01-24 13:46:30 [Protocol] error Connection qpid.127.0.0.1:5672-127.0.0.1:33825 closed by error: invalid conversion: Cannot convert from uint16 to uint8 (/builddir/build/BUILD/qpid-cpp-0.34/src/qpid/types/Variant.cpp:280)(501)


Expected results:
output:
a message is received and printed to stdout

qpid logs:
no error


Additional info:
will commit the fix to upstream

--- Additional comment from Pavel Moravec on 2016-01-24 07:56:21 EST ---

posted to upstream as r1726487.

Comment 3 Zdenek Kraus 2016-02-22 13:23:42 UTC
This fix was tested on RHEL 7 i686 && x86_64 with following packages:
qpid-cpp-client-0.34-6
qpid-cpp-client-devel-0.34-6
qpid-cpp-client-devel-docs-0.34-6
qpid-cpp-client-rdma-0.34-6
qpid-cpp-debuginfo-0.34-6
qpid-cpp-server-0.34-6
qpid-cpp-server-devel-0.34-6
qpid-cpp-server-ha-0.34-6
qpid-cpp-server-linearstore-0.34-6
qpid-cpp-server-rdma-0.34-6
qpid-cpp-server-xml-0.34-6
qpid-proton-c-0.10-2

This fix works as expected.

-> VERIFIED

Comment 4 Zdenek Kraus 2016-02-22 13:26:17 UTC
Correction RHEL 7 x86_64 only, with packages:

qpid-cpp-client-0.34-6.el7.x86_64
qpid-cpp-client-devel-0.34-6.el7.x86_64
qpid-cpp-client-devel-docs-0.34-6.el7.noarch
qpid-cpp-client-rdma-0.34-6.el7.x86_64
qpid-cpp-debuginfo-0.34-6.el7.x86_64
qpid-cpp-server-0.34-6.el7.x86_64
qpid-cpp-server-devel-0.34-6.el7.x86_64
qpid-cpp-server-ha-0.34-6.el7.x86_64
qpid-cpp-server-linearstore-0.34-6.el7.x86_64
qpid-cpp-server-rdma-0.34-6.el7.x86_64
qpid-proton-c-0.10-2.el7.x86_64

Comment 8 errata-xmlrpc 2016-03-14 14:53:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:0444


Note You need to log in before you can comment on or make changes to this bug.