[ 
https://issues.apache.org/jira/browse/QPID-1449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12658713#action_12658713
 ] 

Steve Huston commented on QPID-1449:
------------------------------------

This same issue came up in a different context - setting a message's header 
field value to a zero-length string. This code crashes in the client code:

    qpid::framing::FieldTable& headers = msg.getHeaders ();
    headers.setString("Project", messageId->project);

if messageId->project is a zero-length string, octets gets initialized without 
allocating any memory for octets. Calling octets.size() correctly returns 0, 
but trying to take the address of element 0 yields an invalid pointer and the 
debug stuff in the Visual C++ library flags it as subscript out of range, which 
is correct.

If the code in framing/FieldValue.h is changed from:

    void encode(Buffer& buffer) {
        buffer.putUInt<lenwidth>(octets.size());
        buffer.putRawData(&octets[0], octets.size());
    };
    void decode(Buffer& buffer) {
        uint32_t len = buffer.getUInt<lenwidth>();
        octets.resize(len);
        buffer.getRawData(&octets[0], len);
    }

to check len before taking octets[0] address, it resolves the problem.


> C++ broker on Windows with --mgmt-enable no triggers crash setting up client
> ----------------------------------------------------------------------------
>
>                 Key: QPID-1449
>                 URL: https://issues.apache.org/jira/browse/QPID-1449
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker
>         Environment: Windows
>            Reporter: Steve Huston
>            Assignee: Steve Huston
>
> If the C++ broker is started on Windows with --mgmt-enable no, the exchange 
> to set up a new client causes an assert in the C++ library. This is because 
> the federation tag doesn't have an associated string - when encoding the 
> value for qpid.federation_tag, the value is invalid.
> When running on Linux with the same option, the qpid.federation_tag value is 
> an empty string.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to