/* free up memory and exit */ static void clean_exit(fko_ctx_t ctx, fko_cli_options_t *opts, char *key, int *key_len, char *hmac_key, int *hmac_key_len, unsigned int exit_status) { if(fko_destroy(ctx) == FKO_ERROR_ZERO_OUT_DATA) log_msg(LOG_VERBOSITY_ERROR, "[*] Could not zero out sensitive data buffer."); ctx = NULL; free_configs(opts); zero_buf_wrapper(key, *key_len); zero_buf_wrapper(hmac_key, *hmac_key_len); *key_len = 0; *hmac_key_len = 0; exit(exit_status); }
/* free up memory and exit */ static void clean_exit(fko_ctx_t ctx, fko_cli_options_t *opts, char *key, int *key_len, char *hmac_key, int *hmac_key_len, unsigned int exit_status) { #if HAVE_LIBFIU if(opts->fault_injection_tag[0] != 0x0) fiu_disable(opts->fault_injection_tag); #endif if(fko_destroy(ctx) == FKO_ERROR_ZERO_OUT_DATA) log_msg(LOG_VERBOSITY_ERROR, "[*] Could not zero out sensitive data buffer."); ctx = NULL; free_configs(opts); zero_buf_wrapper(key, *key_len); zero_buf_wrapper(hmac_key, *hmac_key_len); *key_len = 0; *hmac_key_len = 0; exit(exit_status); }
void free_configs(fko_cli_options_t *opts) { if (opts->resolve_url != NULL) free(opts->resolve_url); zero_buf_wrapper(opts->key, MAX_KEY_LEN+1); zero_buf_wrapper(opts->key_base64, MAX_B64_KEY_LEN+1); zero_buf_wrapper(opts->hmac_key, MAX_KEY_LEN+1); zero_buf_wrapper(opts->hmac_key_base64, MAX_B64_KEY_LEN+1); zero_buf_wrapper(opts->gpg_recipient_key, MAX_GPG_KEY_ID); zero_buf_wrapper(opts->gpg_signer_key, MAX_GPG_KEY_ID); zero_buf_wrapper(opts->gpg_home_dir, MAX_PATH_LEN); zero_buf_wrapper(opts->server_command, MAX_LINE_LEN); }