mapSize is consistently larger than the actual size of doxmMap.
This results in an erroneous parse of the resulting payload wherein
the last key-value pair is truncated.
When creating containers, we must specify CborIndefiniteLength unless
we know the exact length the container.
Change-Id: I8beb6bc45ae41531e8a7528d9dbd254a27e14be9
Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10455
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Kevin Kane <kkane@microsoft.com>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
(cherry picked from commit
a909e871afe8a9ea7e0a779302e4d47dac74649d)
Reviewed-on: https://gerrit.iotivity.org/gerrit/11711
Reviewed-by: David Antler <david.a.antler@intel.com>
/** Max cbor size payload. */
static const uint16_t CBOR_MAX_SIZE = 4400;
/** Max cbor size payload. */
static const uint16_t CBOR_MAX_SIZE = 4400;
-/** DOXM Map size - Number of mandatory items. */
-static const uint8_t DOXM_MAP_SIZE = 9;
-
static OicSecDoxm_t *gDoxm = NULL;
static OCResourceHandle gDoxmHandle = NULL;
static OicSecDoxm_t *gDoxm = NULL;
static OCResourceHandle gDoxmHandle = NULL;
char* strUuid = NULL;
int64_t cborEncoderResult = CborNoError;
char* strUuid = NULL;
int64_t cborEncoderResult = CborNoError;
- uint8_t mapSize = DOXM_MAP_SIZE;
- if (doxm->oxmTypeLen > 0)
- {
- mapSize++;
- }
- if (doxm->oxmLen > 0)
- {
- mapSize++;
- }
uint8_t *outPayload = (uint8_t *)OICCalloc(1, cborLen);
VERIFY_NON_NULL(TAG, outPayload, ERROR);
cbor_encoder_init(&encoder, outPayload, cborLen, 0);
uint8_t *outPayload = (uint8_t *)OICCalloc(1, cborLen);
VERIFY_NON_NULL(TAG, outPayload, ERROR);
cbor_encoder_init(&encoder, outPayload, cborLen, 0);
- cborEncoderResult = cbor_encoder_create_map(&encoder, &doxmMap, mapSize);
+ cborEncoderResult = cbor_encoder_create_map(&encoder, &doxmMap, CborIndefiniteLength);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Doxm Map.");
//OxmType -- Not Mandatory
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Doxm Map.");
//OxmType -- Not Mandatory