Coverage Report

Created: 2025-10-10 07:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rauc/subprojects/glib-2.76.5/glib/gspawn-private.h
Line
Count
Source
1
/* gspawn.c - Process launching
2
 *
3
 *  Copyright 2000 Red Hat, Inc.
4
 *  g_execvpe implementation based on GNU libc execvp:
5
 *   Copyright 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
6
 *
7
 * SPDX-License-Identifier: LGPL-2.1-or-later
8
 *
9
 * This library is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 of the License, or (at your option) any later version.
13
 *
14
 * This library is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public License
20
 * along with this library; if not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#include "config.h"
24
25
#include <errno.h>
26
27
#include "glibintl.h"
28
#include "gspawn.h"
29
30
static inline gint
31
_g_spawn_exec_err_to_g_error (gint en)
32
0
{
33
0
  switch (en)
34
0
    {
35
0
#ifdef EACCES
36
0
    case EACCES:
37
0
      return G_SPAWN_ERROR_ACCES;
38
0
#endif
39
40
0
#ifdef EPERM
41
0
    case EPERM:
42
0
      return G_SPAWN_ERROR_PERM;
43
0
#endif
44
45
0
#ifdef E2BIG
46
0
    case E2BIG:
47
0
      return G_SPAWN_ERROR_TOO_BIG;
48
0
#endif
49
50
0
#ifdef ENOEXEC
51
0
    case ENOEXEC:
52
0
      return G_SPAWN_ERROR_NOEXEC;
53
0
#endif
54
55
0
#ifdef ENAMETOOLONG
56
0
    case ENAMETOOLONG:
57
0
      return G_SPAWN_ERROR_NAMETOOLONG;
58
0
#endif
59
60
0
#ifdef ENOENT
61
0
    case ENOENT:
62
0
      return G_SPAWN_ERROR_NOENT;
63
0
#endif
64
65
0
#ifdef ENOMEM
66
0
    case ENOMEM:
67
0
      return G_SPAWN_ERROR_NOMEM;
68
0
#endif
69
70
0
#ifdef ENOTDIR
71
0
    case ENOTDIR:
72
0
      return G_SPAWN_ERROR_NOTDIR;
73
0
#endif
74
75
0
#ifdef ELOOP
76
0
    case ELOOP:
77
0
      return G_SPAWN_ERROR_LOOP;
78
0
#endif
79
80
#ifdef ETXTBUSY
81
    case ETXTBUSY:
82
      return G_SPAWN_ERROR_TXTBUSY;
83
#endif
84
85
0
#ifdef EIO
86
0
    case EIO:
87
0
      return G_SPAWN_ERROR_IO;
88
0
#endif
89
90
0
#ifdef ENFILE
91
0
    case ENFILE:
92
0
      return G_SPAWN_ERROR_NFILE;
93
0
#endif
94
95
0
#ifdef EMFILE
96
0
    case EMFILE:
97
0
      return G_SPAWN_ERROR_MFILE;
98
0
#endif
99
100
0
#ifdef EINVAL
101
0
    case EINVAL:
102
0
      return G_SPAWN_ERROR_INVAL;
103
0
#endif
104
105
0
#ifdef EISDIR
106
0
    case EISDIR:
107
0
      return G_SPAWN_ERROR_ISDIR;
108
0
#endif
109
110
0
#ifdef ELIBBAD
111
0
    case ELIBBAD:
112
0
      return G_SPAWN_ERROR_LIBBAD;
113
0
#endif
114
115
0
    default:
116
0
      return G_SPAWN_ERROR_FAILED;
117
0
    }
118
0
}
119
120
static inline gboolean
121
_g_spawn_invalid_source_fd (gint         fd,
122
                            const gint  *source_fds,
123
                            gsize        n_fds,
124
                            GError     **error)
125
0
{
126
0
  gsize i;
127
128
0
  for (i = 0; i < n_fds; i++)
129
0
    if (fd == source_fds[i])
130
0
      {
131
0
        g_set_error (error,
132
0
                     G_SPAWN_ERROR,
133
0
                     G_SPAWN_ERROR_INVAL,
134
0
                     _("Invalid source FDs argument"));
135
0
        return TRUE;
136
0
      }
137
138
0
  return FALSE;
139
0
}