mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-06 00:00:47 -04:00
- 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)
|
static status_t destroy(private_nonce_payload_t *this)
|
||||||
{
|
{
|
||||||
if (this->nonce.ptr)
|
if (this->nonce.ptr != NULL)
|
||||||
{
|
{
|
||||||
allocator_free(this->nonce.ptr);
|
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)
|
if (nonce.len >= 16 && nonce.len <= 256)
|
||||||
{
|
{
|
||||||
this->nonce.len = nonce.len;
|
this->nonce.len = nonce.len;
|
||||||
this->nonce.ptr = allocator_clone_bytes(nonce.ptr, nonce.len);
|
this->nonce.ptr = nonce.ptr;
|
||||||
if (this->nonce.ptr == NULL)
|
|
||||||
{
|
|
||||||
return OUT_OF_RES;
|
|
||||||
}
|
|
||||||
this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + nonce.len;
|
this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + nonce.len;
|
||||||
return SUCCESS;
|
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)
|
static status_t get_nonce(private_nonce_payload_t *this, chunk_t *nonce)
|
||||||
{
|
{
|
||||||
nonce->len = this->nonce.len;
|
nonce->len = this->nonce.len;
|
||||||
nonce->ptr = allocator_clone_bytes(this->nonce.ptr, this->nonce.len);
|
nonce->ptr = this->nonce.ptr;
|
||||||
if (nonce->ptr == NULL)
|
|
||||||
{
|
|
||||||
return OUT_OF_RES;
|
|
||||||
}
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,10 +49,14 @@ struct nonce_payload_s {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the nonce value.
|
* @brief Set the nonce value.
|
||||||
|
*
|
||||||
|
* The nonce must have length between 16 and 256 bytes
|
||||||
*
|
*
|
||||||
* @param this calling nonce_payload_t object
|
* @param this calling nonce_payload_t object
|
||||||
* @param nonce chunk containing the nonce, will be cloned
|
* @param nonce chunk containing the nonce, will NOT be cloned
|
||||||
* @return SUCCESS in any case
|
* @return
|
||||||
|
* - SUCCESS or
|
||||||
|
* - INVALID_ARG, if nonce has an invalid size
|
||||||
*/
|
*/
|
||||||
status_t (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
|
status_t (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
|
||||||
|
|
||||||
@ -60,7 +64,7 @@ struct nonce_payload_s {
|
|||||||
* @brief Get the nonce value.
|
* @brief Get the nonce value.
|
||||||
*
|
*
|
||||||
* @param this calling nonce_payload_t object
|
* @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
|
* @return SUCCESS in any case
|
||||||
*/
|
*/
|
||||||
status_t (*get_nonce) (nonce_payload_t *this, chunk_t *nonce);
|
status_t (*get_nonce) (nonce_payload_t *this, chunk_t *nonce);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user