Skip to content

2^-14 fails to serialize on little-endian systems #11

Closed
@dgrigsby

Description

From here: http://tools.ietf.org/html/rfc7049#appendix-A
There is this example:
0.00006103515625 -> 0xf90400
It turns out the left hand side is 2^-14.
Using libcbor 0.3.1 on XCode simulator (little-endian), cbor_serialize_alloc fails after cbor_build_float2 for the provided number.
Actually it appears to get into an endless loop until aborted by an illegal malloc request.
Here's a function that demonstrates the issue:

  • (void) testTwoToMinus14
    {
    cbor_item_t* pItem = cbor_build_float2(0.00006103515625);
    unsigned char* buffer;
    size_t buffer_size, length = cbor_serialize_alloc(pItem, &buffer, &buffer_size);
    XCTAssert(length);
    }

Attached is an image showing my test program and the results.
cbor2

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions