X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fsecurity%2Fsrc%2Fcrlresource.c;h=a59df3b9d81f6f3c311e17fc491d32facc0eeeb1;hb=7f00f942c39b7bc27c7eeecf213a239c3fe4173c;hp=9e12aaca2453f7811745f42c1e6bfc98caf89ad0;hpb=edcfc3d2329da7b914771c0dcff5f42c9b74fd93;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/security/src/crlresource.c b/resource/csdk/security/src/crlresource.c index 9e12aac..a59df3b 100644 --- a/resource/csdk/security/src/crlresource.c +++ b/resource/csdk/security/src/crlresource.c @@ -75,7 +75,7 @@ void DeleteCrl(OicSecCrl_t *crl) } } -void printCrl(OicSecCrl_t *crl) +void printCrl(const OicSecCrl_t *crl) { if (NULL == crl) { @@ -362,16 +362,6 @@ OCStackResult CrlToCBORPayload(const OicSecCrl_t *crl, uint8_t **payload, size_t ret = OC_STACK_OK; exit: - if ((CborErrorOutOfMemory == cborEncoderResult) && (cborLen < CBOR_MAX_SIZE)) - { - // reallocate and try again! - OICFree(outPayload); - // Since the allocated initial memory failed, double the memory. - cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end); - cborEncoderResult = CborNoError; - ret = CrlToCBORPayload(crl, payload, &cborLen, lastUpdate); - } - if ((CborNoError != cborEncoderResult) || (OC_STACK_OK != ret)) { OICFree(outPayload); @@ -379,6 +369,13 @@ exit: *payload = NULL; *size = 0; ret = OC_STACK_ERROR; + if ((CborErrorOutOfMemory == cborEncoderResult) && (cborLen < CBOR_MAX_SIZE)) + { + // Since the allocated initial memory failed, double the memory. + cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end); + cborEncoderResult = CborNoError; + ret = CrlToCBORPayload(crl, payload, &cborLen, lastUpdate); + } } return ret; @@ -807,12 +804,12 @@ void GetDerCrl(ByteArray_t* out) { OIC_LOG (ERROR, TAG, "Base64 decoding failed."); } + OICFree(out); } out->len = 0; - char *str = "Can't allocate memory for out->data"; - out->data = OICMalloc(crl->len); + out->data = OICRealloc(out->data, crl->len); if (out->data) { memcpy(out->data, crl->data, crl->len); @@ -820,7 +817,7 @@ void GetDerCrl(ByteArray_t* out) } else { - OIC_LOG_V(ERROR, TAG, "%s", str); + OIC_LOG(ERROR, TAG, "Can't allocate memory for out->data"); } DeleteCrl(crlRes); }