The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
merged_model.c
Go to the documentation of this file.
1/* Coverity Scan model
2 *
3 * This is a modeling file for Coverity Scan. Modeling helps to avoid false
4 * positives.
5 *
6 * - A model file can't #include any header files.
7 * - Therefore only some built-in primitives like int, char and void are
8 * available but not wchar_t, NULL etc.
9 * - Modeling doesn't need full structs and typedefs. Rudimentary structs
10 * and similar types are sufficient.
11 * - An uninitialized local pointer is not an error. It signifies that the
12 * variable could be either NULL or have some data.
13 *
14 * Coverity Scan doesn't pick up modifications automatically. The model file
15 * must be uploaded by an admin in the analysis settings of
16 * https://scan.coverity.com/projects/freeradius-freeradius-server?tab=analysis_settings
17 */
18
19typedef unsigned char bool;
20
21typedef unsigned int mode_t;
22typedef long long int off_t;
23
24typedef long int ssize_t;
25typedef unsigned long int size_t;
26
27typedef union {
29
30typedef unsigned char uint8_t;
31typedef unsigned short uint16_t;
32#define UINT8_MAX 255
33typedef unsigned int uint32_t;
34
36
37typedef struct {
38 char *p;
40
41typedef struct {
44
45typedef enum {
46 FR_SBUFF_PARSE_OK = 0, //!< No error.
47 FR_SBUFF_PARSE_ERROR_NOT_FOUND = -1, //!< String does not contain a token
48 ///< matching the output type.
49 FR_SBUFF_PARSE_ERROR_TRAILING = -2, //!< Trailing characters found.
50 FR_SBUFF_PARSE_ERROR_FORMAT = -3, //!< Format of data was invalid.
51 FR_SBUFF_PARSE_ERROR_OUT_OF_SPACE = -4, //!< No space available in output buffer.
52 FR_SBUFF_PARSE_ERROR_NUM_OVERFLOW = -5, //!< Integer type would overflow.
53 FR_SBUFF_PARSE_ERROR_NUM_UNDERFLOW = -6 //!< Integer type would underflow.
55
57{
58 fr_slen_t result;
59
60 if (result >= 0) __coverity_write_buffer_bytes__(out->p, result);
61
62 return result;
63}
64
66 bool no_trailing, uint8_t const alphabet[static UINT8_MAX + 1])
67{
68 fr_slen_t result;
69
70 if (result >= 0) __coverity_write_buffer_bytes__(out->p, result + 1);
71
72 return result;
73}
74
75/*
76 * Here we can use __coverity_writeall__(), which tells coverity "however big the thing
77 * pointed at is, consider it all written."
78 */
79
80typedef enum {
81 FR_TYPE_NULL = 0, //!< Invalid (uninitialised) attribute type.
82
83 FR_TYPE_STRING, //!< String of printable characters.
84 FR_TYPE_OCTETS, //!< Raw octets.
85
86 FR_TYPE_IPV4_ADDR, //!< 32 Bit IPv4 Address.
87 FR_TYPE_IPV4_PREFIX, //!< IPv4 Prefix.
88 FR_TYPE_IPV6_ADDR, //!< 128 Bit IPv6 Address.
89 FR_TYPE_IPV6_PREFIX, //!< IPv6 Prefix.
90 FR_TYPE_IFID, //!< Interface ID.
91 FR_TYPE_COMBO_IP_ADDR, //!< IPv4 or IPv6 address depending on length.
92 FR_TYPE_COMBO_IP_PREFIX, //!< IPv4 or IPv6 address prefix depending on length.
93 FR_TYPE_ETHERNET, //!< 48 Bit Mac-Address.
94
95 FR_TYPE_BOOL, //!< A truth value.
96
97 FR_TYPE_UINT8, //!< 8 Bit unsigned integer.
98 FR_TYPE_UINT16, //!< 16 Bit unsigned integer.
99 FR_TYPE_UINT32, //!< 32 Bit unsigned integer.
100 FR_TYPE_UINT64, //!< 64 Bit unsigned integer.
101
102
103 FR_TYPE_INT8, //!< 8 Bit signed integer.
104 FR_TYPE_INT16, //!< 16 Bit signed integer.
105 FR_TYPE_INT32, //!< 32 Bit signed integer.
106 FR_TYPE_INT64, //!< 64 Bit signed integer.
107
108 FR_TYPE_FLOAT32, //!< Single precision floating point.
109 FR_TYPE_FLOAT64, //!< Double precision floating point.
110
111 FR_TYPE_DATE, //!< Unix time stamp, always has value >2^31
112
113 FR_TYPE_TIME_DELTA, //!< A period of time measured in nanoseconds.
114
115 FR_TYPE_SIZE, //!< Unsigned integer capable of representing any memory
116 //!< address on the local system.
117
118 FR_TYPE_TLV, //!< Contains nested attributes.
119 FR_TYPE_STRUCT, //!< like TLV, but without T or L, and fixed-width children
120
121 FR_TYPE_VSA, //!< Vendor-Specific, for RADIUS attribute 26.
122 FR_TYPE_VENDOR, //!< Attribute that represents a vendor in the attribute tree.
123
124 FR_TYPE_GROUP, //!< A grouping of other attributes
125 FR_TYPE_VALUE_BOX, //!< A boxed value.
126
127 FR_TYPE_VOID, //!< User data. Should be a talloced chunk
128 ///< assigned to the ptr value of the union.
129
130 FR_TYPE_MAX //!< Number of defined data types.
132
133typedef struct {
135
136typedef struct {
138
139typedef struct {
141
143{
144 ssize_t result;
145
146 if (result >= 0) __coverity_write_buffer_bytes__(out->p, result);
147
148 return result;
149}
150
152 bool const allowed[static UINT8_MAX + 1])
153{
154 size_t result;
155
156 __coverity_write_buffer_bytes__(out->p, result + 1);
157
158 return result;
159}
160
161typedef struct {
163typedef struct {
165
167 fr_sbuff_term_t const *tt,
168 fr_sbuff_unescape_rules_t const *u_rules)
169{
170 size_t result;
171
172 __coverity_write_buffer_bytes__(out->p, result + 1);
173
174 return result;
175}
176
178 fr_sbuff_term_t const *tt,
179 fr_sbuff_unescape_rules_t const *u_rules)
180{
181 size_t result;
182
183 __coverity_write_buffer_bytes__(out->p, result + 1);
184
185 return result;
186}
187
189 fr_dict_attr_t const *ancestor, fr_dict_attr_t const *da, bool numeric)
190{
191 ssize_t result;
192
193 if (result > 0) __coverity_write_buffer_bytes__(out->p, result);
194
195 return result;
196}
197
198typedef struct {
199} fr_dict_t;
200
202{
203 ssize_t result;
204
205 if (result > 0) __coverity_write_buffer_bytes__(out->p, result);
206
207 return result;
208}
209
210typedef struct {
211} request_t;
212
213typedef size_t (*xlat_escape_legacy_t)(request_t *request, char *out, size_t outlen, char const *in, void *arg);
214
215ssize_t xlat_eval(char *out, size_t outlen, request_t *request,
216 char const *fmt, xlat_escape_legacy_t escape, void const *escape_ctx)
217{
218 ssize_t result;
219
220 if (result > 0) __coverity_write_buffer_bytes__(out, result + 1);
221
222 return result;
223}
224
225typedef struct {
226} tmpl_t;
227
228typedef enum {
229 TMPL_ATTR_REF_PREFIX_YES = 0, //!< Attribute refs must have '&' prefix.
230 TMPL_ATTR_REF_PREFIX_NO, //!< Attribute refs have no '&' prefix.
231 TMPL_ATTR_REF_PREFIX_AUTO //!< Attribute refs may have a '&' prefix.
233
234typedef struct {
236
239{
240 fr_slen_t result;
241
242 if (result >= 0) __coverity_write_buffer_bytes__(out->p, result + 1);
243
244 return result;
245}
246
247#ifndef MD5_DIGEST_LENGTH
248# define MD5_DIGEST_LENGTH 16
249#endif
250
252{
253 __coverity_write_buffer_bytes__(out, MD5_DIGEST_LENGTH);
254}
255
256typedef struct {
258
259bool fr_radius_ok(uint8_t const *packet, size_t *packet_len_p,
260 uint32_t max_attributes, bool require_message_authenticator, decode_fail_t *reason)
261{
262 bool result;
263
264 if (result) {
265 __coverity_mark_pointee_as_sanitized__(&packet, TAINTED_SCALAR_GENERIC);
266 __coverity_mark_pointee_as_sanitized__(packet, TAINTED_SCALAR_GENERIC);
267 __coverity_mark_pointee_as_sanitized__(packet_len_p, TAINTED_SCALAR_GENERIC);
268 }
269 return result;
270}
271
272typedef struct {
274
275int fr_inet_pton4(fr_ipaddr_t *out, char const *value, ssize_t inlen, bool resolve, bool fallback, bool mask_bits)
276{
277 int result;
278
279 __coverity_writeall__(out);
280 return result;
281}
static int const char * fmt
Definition acutest.h:573
static fr_slen_t err
Definition dict.h:824
static fr_slen_t in
Definition dict.h:824
Values of the encryption flags.
Test enumeration values.
Definition dict_test.h:92
IPv4/6 prefix.
tmpl_attr_prefix_t
@ TMPL_ATTR_REF_PREFIX_NO
Attribute refs have no '&' prefix.
@ TMPL_ATTR_REF_PREFIX_AUTO
Attribute refs may have a '&' prefix.
@ TMPL_ATTR_REF_PREFIX_YES
Attribute refs must have '&' prefix.
#define MD5_DIGEST_LENGTH
bool fr_radius_ok(uint8_t const *packet, size_t *packet_len_p, uint32_t max_attributes, bool require_message_authenticator, decode_fail_t *reason)
unsigned short uint16_t
fr_slen_t tmpl_print(fr_sbuff_t *out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix, fr_sbuff_escape_rules_t const *e_rules)
size_t(* xlat_escape_legacy_t)(request_t *request, char *out, size_t outlen, char const *in, void *arg)
size_t fr_sbuff_out_unescape_until(fr_sbuff_t *out, fr_sbuff_t *in, size_t len, fr_sbuff_term_t const *tt, fr_sbuff_unescape_rules_t const *u_rules)
fr_type_t
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
@ FR_TYPE_FLOAT32
Single precision floating point.
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_INT8
8 Bit signed integer.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_ETHERNET
48 Bit Mac-Address.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_MAX
Number of defined data types.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_INT64
64 Bit signed integer.
@ FR_TYPE_INT16
16 Bit signed integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.
@ FR_TYPE_VALUE_BOX
A boxed value.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_INT32
32 Bit signed integer.
@ FR_TYPE_VENDOR
Attribute that represents a vendor in the attribute tree.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
@ FR_TYPE_VOID
User data.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
@ FR_TYPE_IFID
Interface ID.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_TYPE_GROUP
A grouping of other attributes.
@ FR_TYPE_FLOAT64
Double precision floating point.
uint8_t * p
unsigned int uint32_t
ssize_t fr_dict_attr_flags_print(fr_sbuff_t *out, fr_dict_t const *dict, fr_type_t type, fr_dict_attr_flags_t const *flags)
int fr_inet_pton4(fr_ipaddr_t *out, char const *value, ssize_t inlen, bool resolve, bool fallback, bool mask_bits)
fr_slen_t fr_base16_encode_nstd(fr_sbuff_t *out, fr_dbuff_t *in, char const alphabet[static UINT8_MAX+1])
long int ssize_t
ssize_t fr_sbuff_out_bstrncpy_exact(fr_sbuff_t *out, fr_sbuff_t *in, size_t len)
ssize_t fr_dict_attr_oid_print(fr_sbuff_t *out, fr_dict_attr_t const *ancestor, fr_dict_attr_t const *da, bool numeric)
size_t fr_sbuff_out_bstrncpy_until(fr_sbuff_t *out, fr_sbuff_t *in, size_t len, fr_sbuff_term_t const *tt, fr_sbuff_unescape_rules_t const *u_rules)
unsigned char bool
ssize_t xlat_eval(char *out, size_t outlen, request_t *request, char const *fmt, xlat_escape_legacy_t escape, void const *escape_ctx)
void fr_md5_calc(uint8_t out[static MD5_DIGEST_LENGTH], uint8_t const *in, size_t inlen)
Perform a single digest operation on a single input buffer.
unsigned char uint8_t
fr_slen_t fr_base16_decode_nstd(fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr_sbuff_t *in, bool no_trailing, uint8_t const alphabet[static UINT8_MAX+1])
unsigned int mode_t
ssize_t fr_slen_t
long long int off_t
unsigned long int size_t
#define UINT8_MAX
fr_sbuff_parse_error_t
@ FR_SBUFF_PARSE_ERROR_NUM_OVERFLOW
Integer type would overflow.
@ FR_SBUFF_PARSE_ERROR_NUM_UNDERFLOW
Integer type would underflow.
@ FR_SBUFF_PARSE_ERROR_NOT_FOUND
String does not contain a token matching the output type.
@ FR_SBUFF_PARSE_ERROR_FORMAT
Format of data was invalid.
@ FR_SBUFF_PARSE_OK
No error.
@ FR_SBUFF_PARSE_ERROR_OUT_OF_SPACE
No space available in output buffer.
@ FR_SBUFF_PARSE_ERROR_TRAILING
Trailing characters found.
size_t fr_sbuff_out_bstrncpy_allowed(fr_sbuff_t *out, fr_sbuff_t *in, size_t len, bool const allowed[static UINT8_MAX+1])
Set of terminal elements.
Set of parsing rules for *unescape_until functions.
static fr_slen_t ar_prefix
Definition tmpl.h:1279
static fr_slen_t vpt
Definition tmpl.h:1272
fr_aka_sim_id_type_t type
static size_t char fr_sbuff_t size_t inlen
Definition value.h:997
static size_t char ** out
Definition value.h:997