if (ctx->encoded_msg_len - t_size < 0)
return(FKO_ERROR_INVALID_DATA);
+ if(ctx->digest != NULL)
+ free(ctx->digest);
+
/* Copy the digest into the context and terminate the encoded data
* at that point so the original digest is not part of the
* encoded string.
case FKO_DIGEST_SHA512:
sha512_base64(tbuf, (unsigned char*)ctx->encoded_msg, ctx->encoded_msg_len);
break;
-
}
/* We give up here if the computed digest does not match the
return(FKO_ERROR_INVALID_DATA);
}
+ if(ctx->rand_val != NULL)
+ free(ctx->rand_val);
+
ctx->rand_val = calloc(1, FKO_RAND_VAL_SIZE+1);
if(ctx->rand_val == NULL)
{
strlcpy(tbuf, ndx, t_size+1);
+ if(ctx->username != NULL)
+ free(ctx->username);
+
ctx->username = malloc(t_size+1); /* Yes, more than we need */
if(ctx->username == NULL)
{
return(FKO_ERROR_INVALID_DATA);
}
+ if(ctx->version != NULL)
+ free(ctx->version);
+
ctx->version = malloc(t_size+1);
if(ctx->version == NULL)
{
strlcpy(tbuf, ndx, t_size+1);
+ if(ctx->message != NULL)
+ free(ctx->message);
+
ctx->message = malloc(t_size+1); /* Yes, more than we need */
if(ctx->message == NULL)
{
strlcpy(tbuf, ndx, t_size+1);
+ if(ctx->nat_access != NULL)
+ free(ctx->nat_access);
+
ctx->nat_access = malloc(t_size+1); /* Yes, more than we need */
if(ctx->nat_access == NULL)
{
{
strlcpy(tbuf, ndx, t_size+1);
+ if(ctx->server_auth != NULL)
+ free(ctx->server_auth);
+
ctx->server_auth = malloc(t_size+1); /* Yes, more than we need */
if(ctx->server_auth == NULL)
{
*/
strlcpy(tbuf, ndx, t_size+1);
+ if(ctx->server_auth != NULL)
+ free(ctx->server_auth);
+
ctx->server_auth = malloc(t_size+1); /* Yes, more than we need */
if(ctx->server_auth == NULL)
{
FKO_SET_CTX_INITIALIZED(ctx);
- if(r_ctx != NULL)
- fko_destroy(*r_ctx);
-
*r_ctx = ctx;
return(FKO_SUCCESS);
return(FKO_ERROR_INVALID_DATA);
}
+ if(ctx->encrypted_msg != NULL)
+ free(ctx->encrypted_msg);
+
/* First, add the data to the context.
*/
ctx->encrypted_msg = strdup(enc_msg);
if(! is_valid_encoded_msg_len(enc_msg_len))
return(FKO_ERROR_INVALID_DATA);
+ if(ctx->encrypted_msg != NULL)
+ free(ctx->encrypted_msg);
+
/* First, add the data to the context.
*/
ctx->encrypted_msg = strdup(enc_msg);