Coverage Report

Created: 2023-06-07 06:47

/src/sudo/lib/eventlog/eventlog_free.c
Line
Count
Source
1
/*
2
 * SPDX-License-Identifier: ISC
3
 *
4
 * Copyright (c) 2020 Todd C. Miller <Todd.Miller@sudo.ws>
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
8
 * copyright notice and this permission notice appear in all copies.
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 *
18
 * Sponsored in part by the Defense Advanced Research Projects
19
 * Agency (DARPA) and Air Force Research Laboratory, Air Force
20
 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
21
 */
22
23
/*
24
 * This is an open source non-commercial project. Dear PVS-Studio, please check it.
25
 * PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
26
 */
27
28
#include <config.h>
29
30
#include <stdio.h>
31
#include <stdlib.h>
32
33
#include "sudo_compat.h"
34
#include "sudo_debug.h"
35
#include "sudo_eventlog.h"
36
#include "sudo_util.h"
37
38
/*
39
 * Free the strings in a struct eventlog.
40
 */
41
void
42
eventlog_free(struct eventlog *evlog)
43
3.20k
{
44
3.20k
    int i;
45
3.20k
    debug_decl(eventlog_free, SUDO_DEBUG_UTIL);
46
47
3.20k
    if (evlog != NULL) {
48
3.20k
  free(evlog->iolog_path);
49
3.20k
  free(evlog->command);
50
3.20k
  free(evlog->cwd);
51
3.20k
  free(evlog->runchroot);
52
3.20k
  free(evlog->runcwd);
53
3.20k
  free(evlog->rungroup);
54
3.20k
  free(evlog->runuser);
55
3.20k
  free(evlog->peeraddr);
56
3.20k
  free(evlog->signal_name);
57
3.20k
  free(evlog->submithost);
58
3.20k
  free(evlog->submituser);
59
3.20k
  free(evlog->submitgroup);
60
3.20k
  free(evlog->ttyname);
61
3.20k
  if (evlog->argv != NULL) {
62
241
      for (i = 0; evlog->argv[i] != NULL; i++)
63
203
    free(evlog->argv[i]);
64
38
      free(evlog->argv);
65
38
  }
66
3.20k
  if (evlog->envp != NULL) {
67
524k
      for (i = 0; evlog->envp[i] != NULL; i++)
68
524k
    free(evlog->envp[i]);
69
61
      free(evlog->envp);
70
61
  }
71
3.20k
  if (evlog->env_add != NULL) {
72
241
      for (i = 0; evlog->env_add[i] != NULL; i++)
73
203
    free(evlog->env_add[i]);
74
38
      free(evlog->env_add);
75
38
  }
76
3.20k
  free(evlog);
77
3.20k
    }
78
79
3.20k
    debug_return;
80
3.20k
}