- change cloning behavior, does not clone anymore
This commit is contained in:
parent
14e635db50
commit
b722736c2f
|
@ -106,7 +106,7 @@ encoding_rule_t nonce_payload_encodings[] = {
|
|||
*/
|
||||
static status_t destroy(private_nonce_payload_t *this)
|
||||
{
|
||||
if (this->nonce.ptr)
|
||||
if (this->nonce.ptr != NULL)
|
||||
{
|
||||
allocator_free(this->nonce.ptr);
|
||||
}
|
||||
|
@ -124,11 +124,7 @@ static status_t set_nonce(private_nonce_payload_t *this, chunk_t nonce)
|
|||
if (nonce.len >= 16 && nonce.len <= 256)
|
||||
{
|
||||
this->nonce.len = nonce.len;
|
||||
this->nonce.ptr = allocator_clone_bytes(nonce.ptr, nonce.len);
|
||||
if (this->nonce.ptr == NULL)
|
||||
{
|
||||
return OUT_OF_RES;
|
||||
}
|
||||
this->nonce.ptr = nonce.ptr;
|
||||
this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + nonce.len;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -142,11 +138,7 @@ static status_t set_nonce(private_nonce_payload_t *this, chunk_t nonce)
|
|||
static status_t get_nonce(private_nonce_payload_t *this, chunk_t *nonce)
|
||||
{
|
||||
nonce->len = this->nonce.len;
|
||||
nonce->ptr = allocator_clone_bytes(this->nonce.ptr, this->nonce.len);
|
||||
if (nonce->ptr == NULL)
|
||||
{
|
||||
return OUT_OF_RES;
|
||||
}
|
||||
nonce->ptr = this->nonce.ptr;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,10 +49,14 @@ struct nonce_payload_s {
|
|||
|
||||
/**
|
||||
* @brief Set the nonce value.
|
||||
*
|
||||
* The nonce must have length between 16 and 256 bytes
|
||||
*
|
||||
* @param this calling nonce_payload_t object
|
||||
* @param nonce chunk containing the nonce, will be cloned
|
||||
* @return SUCCESS in any case
|
||||
* @param nonce chunk containing the nonce, will NOT be cloned
|
||||
* @return
|
||||
* - SUCCESS or
|
||||
* - INVALID_ARG, if nonce has an invalid size
|
||||
*/
|
||||
status_t (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
|
||||
|
||||
|
@ -60,7 +64,7 @@ struct nonce_payload_s {
|
|||
* @brief Get the nonce value.
|
||||
*
|
||||
* @param this calling nonce_payload_t object
|
||||
* @param[out] nonce chunk where the cloned nonce data is located
|
||||
* @param[out] nonce chunk where nonce data is located (NOT cloned)
|
||||
* @return SUCCESS in any case
|
||||
*/
|
||||
status_t (*get_nonce) (nonce_payload_t *this, chunk_t *nonce);
|
||||
|
|
Loading…
Reference in New Issue