/*1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2020, 2023, 2025 Todd C. Miller <[email protected]>4*5* Permission to use, copy, modify, and distribute this software for any6* purpose with or without fee is hereby granted, provided that the above7* copyright notice and this permission notice appear in all copies.8*9* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES10* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF11* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR12* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES13* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN14* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF15* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.16*17* Sponsored in part by the Defense Advanced Research Projects18* Agency (DARPA) and Air Force Research Laboratory, Air Force19* Materiel Command, USAF, under agreement number F39502-99-1-0512.20*/2122#include <config.h>2324#include <stdio.h>25#include <stdlib.h>2627#include <sudo_compat.h>28#include <sudo_debug.h>29#include <sudo_eventlog.h>30#include <sudo_util.h>3132/*33* Free the strings in a struct eventlog.34*/35void36eventlog_free_contents(struct eventlog *evlog)37{38size_t i;39debug_decl(eventlog_free_contents, SUDO_DEBUG_UTIL);4041free(evlog->iolog_path);42free(evlog->command);43free(evlog->cwd);44free(evlog->runchroot);45free(evlog->runcwd);46free(evlog->rungroup);47free(evlog->runuser);48free(evlog->peeraddr);49free(evlog->signal_name);50free(evlog->source);51if (evlog->submitenv != NULL) {52for (i = 0; evlog->submitenv[i] != NULL; i++)53free(evlog->submitenv[i]);54free(evlog->submitenv);55}56free(evlog->submithost);57free(evlog->submituser);58free(evlog->submitgroup);59free(evlog->ttyname);60if (evlog->runargv != NULL) {61for (i = 0; evlog->runargv[i] != NULL; i++)62free(evlog->runargv[i]);63free(evlog->runargv);64}65if (evlog->runenv != NULL) {66for (i = 0; evlog->runenv[i] != NULL; i++)67free(evlog->runenv[i]);68free(evlog->runenv);69}70if (evlog->env_add != NULL) {71for (i = 0; evlog->env_add[i] != NULL; i++)72free(evlog->env_add[i]);73free(evlog->env_add);74}7576debug_return;77}7879/*80* Free the strings in a struct eventlog and the eventlog container itself.81*/82void83eventlog_free(struct eventlog *evlog)84{85debug_decl(eventlog_free, SUDO_DEBUG_UTIL);8687if (evlog != NULL) {88eventlog_free_contents(evlog);89free(evlog);90}9192debug_return;93}949596