Bug Summary

File:src/usr.sbin/radiusd/radiusd/obj/parse.c
Warning:line 1210, column 13
Result of 'calloc' is converted to a pointer of type 'char *', which is incompatible with sizeof operand type 'char **'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.4 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name parse.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/usr.sbin/radiusd/radiusd/obj -resource-dir /usr/local/llvm16/lib/clang/16 -I /usr/src/usr.sbin/radiusd/radiusd/.. -internal-isystem /usr/local/llvm16/lib/clang/16/include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/usr/src/usr.sbin/radiusd/radiusd/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fcf-protection=branch -fno-jump-tables -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/scan/2024-01-11-140451-98009-1 -x c parse.c
1#include <stdlib.h>
2#include <string.h>
3#define YYBYACC1 1
4#define YYMAJOR1 1
5#define YYMINOR9 9
6#define YYLEXyylex() yylex()
7#define YYEMPTY-1 -1
8#define yyclearin(yychar=(-1)) (yychar=(YYEMPTY-1))
9#define yyerrok(yyerrflag=0) (yyerrflag=0)
10#define YYRECOVERING()(yyerrflag!=0) (yyerrflag!=0)
11#define YYPREFIX"yy" "yy"
12#line 23 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
13#include <sys/types.h>
14#include <sys/queue.h>
15#include <sys/socket.h>
16
17#include <ctype.h>
18#include <errno(*__errno()).h>
19#include <limits.h>
20#include <netdb.h>
21#include <stdarg.h>
22#include <stdio.h>
23#include <syslog.h>
24
25#include "radiusd.h"
26#include "radiusd_local.h"
27#include "log.h"
28
29static struct radiusd *conf;
30static struct radiusd_authentication authen;
31static struct radiusd_client client;
32
33static struct radiusd_module *find_module (const char *);
34static void free_str_l (void *);
35static struct radiusd_module_ref *create_module_ref (const char *);
36static void radiusd_authentication_init (struct radiusd_authentication *);
37static void radiusd_client_init (struct radiusd_client *);
38
39TAILQ_HEAD(files, file)struct files { struct file *tqh_first; struct file **tqh_last
; }
files = TAILQ_HEAD_INITIALIZER(files){ ((void *)0), &(files).tqh_first };
40static struct file {
41 TAILQ_ENTRY(file)struct { struct file *tqe_next; struct file **tqe_prev; } entry;
42 FILE *stream;
43 char *name;
44 int lineno;
45 int errors;
46} *file, *topfile;
47struct file *pushfile(const char *);
48int popfile(void);
49int yyparse(void);
50int yylex(void);
51int yyerror(const char *, ...)
52 __attribute__((__format__ (printf, 1, 2)))
53 __attribute__((__nonnull__ (1)));
54int kw_cmp(const void *, const void *);
55int lookup(char *);
56int lgetc(int);
57int lungetc(int);
58int findeol(void);
59
60typedef struct {
61 union {
62 int64_t number;
63 char *string;
64 struct radiusd_listen listen;
65 int yesno;
66 struct {
67 char **v;
68 int c;
69 } str_l;
70 struct {
71 int af;
72 struct radiusd_addr addr;
73 struct radiusd_addr mask;
74 } prefix;
75 } v;
76 int lineno;
77} YYSTYPE;
78
79#line 80 "parse.c"
80#define INCLUDE257 257
81#define LISTEN258 258
82#define ON259 259
83#define PORT260 260
84#define CLIENT261 261
85#define SECRET262 262
86#define LOAD263 263
87#define MODULE264 264
88#define MSGAUTH_REQUIRED265 265
89#define AUTHENTICATE266 266
90#define AUTHENTICATE_BY267 267
91#define DECORATE_BY268 268
92#define SET269 269
93#define ERROR270 270
94#define YES271 271
95#define NO272 272
96#define STRING273 273
97#define NUMBER274 274
98#define YYERRCODE256 256
99const short yylhs[] =
100 { -1,
101 0, 0, 0, 0, 0, 0, 0, 0, 8, 9,
102 2, 1, 1, 13, 10, 15, 15, 16, 16, 16,
103 4, 11, 11, 7, 7, 17, 12, 18, 18, 19,
104 19, 19, 3, 3, 6, 6, 14, 14, 5, 5,
105};
106const short yylen[] =
107 { 2,
108 0, 2, 3, 3, 3, 3, 3, 3, 2, 3,
109 2, 0, 2, 0, 7, 3, 1, 2, 2, 0,
110 3, 4, 5, 1, 1, 0, 7, 3, 1, 2,
111 2, 0, 2, 1, 1, 1, 0, 1, 1, 1,
112};
113const short yydefred[] =
114 { 1,
115 0, 0, 0, 0, 14, 0, 26, 2, 0, 0,
116 0, 0, 0, 8, 9, 0, 0, 0, 0, 0,
117 3, 4, 5, 6, 7, 0, 10, 0, 0, 0,
118 0, 35, 36, 0, 34, 0, 11, 0, 38, 0,
119 22, 25, 24, 0, 33, 0, 13, 21, 0, 0,
120 0, 0, 0, 0, 17, 0, 0, 0, 29, 18,
121 39, 40, 19, 0, 15, 30, 0, 0, 27, 16,
122 28,
123};
124const short yydgoto[] =
125 { 1,
126 37, 27, 34, 29, 63, 35, 44, 9, 10, 11,
127 12, 13, 17, 40, 54, 55, 20, 58, 59,
128};
129const short yysindex[] =
130 { 0,
131 -9, 6, -263, -237, 0, -252, 0, 0, 16, 17,
132 18, 19, 20, 0, 0, -242, -241, -240, -239, -260,
133 0, 0, 0, 0, 0, -225, 0, -11, 27, -235,
134 -253, 0, 0, -10, 0, -233, 0, -232, 0, -84,
135 0, 0, 0, -260, 0, -80, 0, 0, -250, -260,
136 -249, -229, -247, -8, 0, -228, -260, -7, 0, 0,
137 0, 0, 0, -250, 0, 0, -260, -249, 0, 0,
138 0,};
139const short yyrindex[] =
140 { 0,
141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
143 0, 0, 0, 0, 0, 36, 0, 0, -76, 0,
144 0, 0, 0, -76, 0, 0, 0, 0, 0, 0,
145 0, 0, 0, 0, 0, 0, 0, 0, -6, 18,
146 -5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
147 0, 0, 0, -6, 0, 0, -4, -5, 0, 0,
148 0,};
149const short yygindex[] =
150 { 0,
151 0, 0, -36, 0, 0, -27, 0, 0, 0, 0,
152 0, 0, 0, 14, 0, -15, 0, 0, -18,
153};
154#define YYTABLESIZE264 264
155const short yytable[] =
156 { 39,
157 8, 64, 68, 20, 32, 31, 45, 50, 42, 15,
158 18, 52, 32, 33, 53, 14, 19, 56, 57, 43,
159 67, 16, 45, 61, 62, 21, 22, 23, 24, 25,
160 26, 28, 30, 31, 36, 38, 39, 41, 49, 45,
161 47, 48, 51, 60, 66, 12, 37, 46, 70, 71,
162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
165 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
166 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
167 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
168 0, 0, 0, 0, 0, 0, 65, 69, 20, 32,
169 31, 0, 0, 0, 0, 0, 0, 0, 0, 0,
170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
171 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
172 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
173 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
174 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
178 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
181 0, 0, 0, 0, 0, 0, 2, 3, 4, 0,
182 0, 5, 0, 0, 6, 0, 7, 0, 0, 0,
183 0, 0, 32, 33,
184};
185const short yycheck[] =
186 { 10,
187 10, 10, 10, 10, 10, 10, 34, 44, 262, 273,
188 263, 262, 273, 274, 265, 10, 269, 267, 268, 273,
189 57, 259, 50, 271, 272, 10, 10, 10, 10, 10,
190 273, 273, 273, 273, 260, 47, 10, 273, 123, 67,
191 274, 274, 123, 273, 273, 10, 123, 34, 64, 68,
192 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
193 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
194 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
195 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
196 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
197 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
198 -1, -1, -1, -1, -1, -1, 125, 125, 125, 125,
199 125, -1, -1, -1, -1, -1, -1, -1, -1, -1,
200 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
201 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
202 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
203 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
204 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
205 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
206 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
207 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
208 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
209 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
210 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
211 -1, -1, -1, -1, -1, -1, 256, 257, 258, -1,
212 -1, 261, -1, -1, 264, -1, 266, -1, -1, -1,
213 -1, -1, 273, 274,
214};
215#define YYFINAL1 1
216#ifndef YYDEBUG0
217#define YYDEBUG0 0
218#endif
219#define YYMAXTOKEN274 274
220#if YYDEBUG0
221const char * const yyname[] =
222 {
223"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2260,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2270,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2280,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2290,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"INCLUDE",
230"LISTEN","ON","PORT","CLIENT","SECRET","LOAD","MODULE","MSGAUTH_REQUIRED",
231"AUTHENTICATE","AUTHENTICATE_BY","DECORATE_BY","SET","ERROR","YES","NO",
232"STRING","NUMBER",
233};
234const char * const yyrule[] =
235 {"$accept : grammar",
236"grammar :",
237"grammar : grammar '\\n'",
238"grammar : grammar include '\\n'",
239"grammar : grammar listen '\\n'",
240"grammar : grammar client '\\n'",
241"grammar : grammar module '\\n'",
242"grammar : grammar authenticate '\\n'",
243"grammar : grammar error '\\n'",
244"include : INCLUDE STRING",
245"listen : LISTEN ON listen_addr",
246"listen_addr : STRING optport",
247"optport :",
248"optport : PORT NUMBER",
249"$$1 :",
250"client : CLIENT $$1 prefix optnl '{' clientopts '}'",
251"clientopts : clientopts '\\n' clientopt",
252"clientopts : clientopt",
253"clientopt : SECRET STRING",
254"clientopt : MSGAUTH_REQUIRED yesno",
255"clientopt :",
256"prefix : STRING '/' NUMBER",
257"module : MODULE LOAD STRING STRING",
258"module : MODULE SET STRING key str_l",
259"key : STRING",
260"key : SECRET",
261"$$2 :",
262"authenticate : AUTHENTICATE $$2 str_l optnl '{' authopts '}'",
263"authopts : authopts '\\n' authopt",
264"authopts : authopt",
265"authopt : AUTHENTICATE_BY STRING",
266"authopt : DECORATE_BY str_l",
267"authopt :",
268"str_l : str_l strnum",
269"str_l : strnum",
270"strnum : STRING",
271"strnum : NUMBER",
272"optnl :",
273"optnl : '\\n'",
274"yesno : YES",
275"yesno : NO",
276};
277#endif
278#ifdef YYSTACKSIZE10000
279#undef YYMAXDEPTH10000
280#define YYMAXDEPTH10000 YYSTACKSIZE10000
281#else
282#ifdef YYMAXDEPTH10000
283#define YYSTACKSIZE10000 YYMAXDEPTH10000
284#else
285#define YYSTACKSIZE10000 10000
286#define YYMAXDEPTH10000 10000
287#endif
288#endif
289#define YYINITSTACKSIZE200 200
290/* LINTUSED */
291int yydebug;
292int yynerrs;
293int yyerrflag;
294int yychar;
295short *yyssp;
296YYSTYPE *yyvsp;
297YYSTYPE yyval;
298YYSTYPE yylval;
299short *yyss;
300short *yysslim;
301YYSTYPE *yyvs;
302unsigned int yystacksize;
303int yyparse(void);
304#line 404 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
305
306struct keywords {
307 const char *k_name;
308 int k_val;
309};
310
311int
312yyerror(const char *fmt, ...)
313{
314 va_list ap;
315 char *msg;
316
317 file->errors++;
318 va_start(ap, fmt)__builtin_va_start((ap), fmt);
319 if (vasprintf(&msg, fmt, ap) == -1)
320 fatalx("yyerror vasprintf");
321 va_end(ap)__builtin_va_end((ap));
322 logit(LOG_CRIT2, "%s:%d: %s", file->name, yylval.lineno, msg);
323 free(msg);
324 return (0);
325}
326
327int
328kw_cmp(const void *k, const void *e)
329{
330 return (strcmp(k, ((const struct keywords *)e)->k_name));
331}
332
333int
334lookup(char *s)
335{
336 /* this has to be sorted always */
337 static const struct keywords keywords[] = {
338 { "authenticate", AUTHENTICATE266},
339 { "authenticate-by", AUTHENTICATE_BY267},
340 { "client", CLIENT261},
341 { "decorate-by", DECORATE_BY268},
342 { "include", INCLUDE257},
343 { "listen", LISTEN258},
344 { "load", LOAD263},
345 { "module", MODULE264},
346 { "msgauth-required", MSGAUTH_REQUIRED265},
347 { "no", NO272},
348 { "on", ON259},
349 { "port", PORT260},
350 { "secret", SECRET262},
351 { "set", SET269},
352 { "yes", YES271},
353 };
354 const struct keywords *p;
355
356 p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]),
357 sizeof(keywords[0]), kw_cmp);
358
359 if (p)
360 return (p->k_val);
361 else
362 return (STRING273);
363}
364
365#define MAXPUSHBACK128 128
366
367char *parsebuf;
368int parseindex;
369char pushback_buffer[MAXPUSHBACK128];
370int pushback_index = 0;
371
372int
373lgetc(int quotec)
374{
375 int c, next;
376
377 if (parsebuf) {
378 /* Read character from the parsebuffer instead of input. */
379 if (parseindex >= 0) {
380 c = (unsigned char)parsebuf[parseindex++];
381 if (c != '\0')
382 return (c);
383 parsebuf = NULL((void *)0);
384 } else
385 parseindex++;
386 }
387
388 if (pushback_index)
389 return ((unsigned char)pushback_buffer[--pushback_index]);
390
391 if (quotec) {
392 if ((c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget
(file->stream) : (int)(*(file->stream)->_p++)) : (getc
)(file->stream))
) == EOF(-1)) {
393 yyerror("reached end of file while parsing "
394 "quoted string");
395 if (file == topfile || popfile() == EOF(-1))
396 return (EOF(-1));
397 return (quotec);
398 }
399 return (c);
400 }
401
402 while ((c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget
(file->stream) : (int)(*(file->stream)->_p++)) : (getc
)(file->stream))
) == '\\') {
403 next = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget
(file->stream) : (int)(*(file->stream)->_p++)) : (getc
)(file->stream))
;
404 if (next != '\n') {
405 c = next;
406 break;
407 }
408 yylval.lineno = file->lineno;
409 file->lineno++;
410 }
411
412 while (c == EOF(-1)) {
413 if (file == topfile || popfile() == EOF(-1))
414 return (EOF(-1));
415 c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget
(file->stream) : (int)(*(file->stream)->_p++)) : (getc
)(file->stream))
;
416 }
417 return (c);
418}
419
420int
421lungetc(int c)
422{
423 if (c == EOF(-1))
424 return (EOF(-1));
425 if (parsebuf) {
426 parseindex--;
427 if (parseindex >= 0)
428 return (c);
429 }
430 if (pushback_index + 1 >= MAXPUSHBACK128)
431 return (EOF(-1));
432 pushback_buffer[pushback_index++] = c;
433 return (c);
434}
435
436int
437findeol(void)
438{
439 int c;
440
441 parsebuf = NULL((void *)0);
442
443 /* skip to either EOF or the first real EOL */
444 while (1) {
445 if (pushback_index)
446 c = (unsigned char)pushback_buffer[--pushback_index];
447 else
448 c = lgetc(0);
449 if (c == '\n') {
450 file->lineno++;
451 break;
452 }
453 if (c == EOF(-1))
454 break;
455 }
456 return (ERROR270);
457}
458
459int
460yylex(void)
461{
462 char buf[8096];
463 char *p;
464 int quotec, next, c;
465 int token;
466
467 p = buf;
468 while ((c = lgetc(0)) == ' ' || c == '\t')
469 ; /* nothing */
470
471 yylval.lineno = file->lineno;
472 if (c == '#')
473 while ((c = lgetc(0)) != '\n' && c != EOF(-1))
474 ; /* nothing */
475
476 switch (c) {
477 case '\'':
478 case '"':
479 quotec = c;
480 while (1) {
481 if ((c = lgetc(quotec)) == EOF(-1))
482 return (0);
483 if (c == '\n') {
484 file->lineno++;
485 continue;
486 } else if (c == '\\') {
487 if ((next = lgetc(quotec)) == EOF(-1))
488 return (0);
489 if (next == quotec || next == ' ' ||
490 next == '\t')
491 c = next;
492 else if (next == '\n') {
493 file->lineno++;
494 continue;
495 } else
496 lungetc(next);
497 } else if (c == quotec) {
498 *p = '\0';
499 break;
500 } else if (c == '\0') {
501 yyerror("syntax error");
502 return (findeol());
503 }
504 if (p + 1 >= buf + sizeof(buf) - 1) {
505 yyerror("string too long");
506 return (findeol());
507 }
508 *p++ = c;
509 }
510 yylval.v.string = strdup(buf);
511 if (yylval.v.string == NULL((void *)0))
512 fatal("yylex: strdup");
513 return (STRING273);
514 }
515
516#define allowed_to_end_number(x)(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' ||
x == '=')
\
517 (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=')
518
519 if (c == '-' || isdigit(c)) {
520 do {
521 *p++ = c;
522 if ((size_t)(p-buf) >= sizeof(buf)) {
523 yyerror("string too long");
524 return (findeol());
525 }
526 } while ((c = lgetc(0)) != EOF(-1) && isdigit(c));
527 lungetc(c);
528 if (p == buf + 1 && buf[0] == '-')
529 goto nodigits;
530 if (c == EOF(-1) || allowed_to_end_number(c)(isspace(c) || c == ')' || c ==',' || c == '/' || c == '}' ||
c == '=')
) {
531 const char *errstr = NULL((void *)0);
532
533 *p = '\0';
534 yylval.v.number = strtonum(buf, LLONG_MIN(-0x7fffffffffffffffLL-1),
535 LLONG_MAX0x7fffffffffffffffLL, &errstr);
536 if (errstr) {
537 yyerror("\"%s\" invalid number: %s",
538 buf, errstr);
539 return (findeol());
540 }
541 return (NUMBER274);
542 } else {
543nodigits:
544 while (p > buf + 1)
545 lungetc((unsigned char)*--p);
546 c = (unsigned char)*--p;
547 if (c == '-')
548 return (c);
549 }
550 }
551
552#define allowed_in_string(x)(isalnum(x) || (ispunct(x) && x != '(' && x !=
')' && x != '{' && x != '}' && x != '<'
&& x != '>' && x != '!' && x != '='
&& x != '/' && x != '#' && x != ',')
)
\
553 (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
554 x != '{' && x != '}' && x != '<' && x != '>' && \
555 x != '!' && x != '=' && x != '/' && x != '#' && \
556 x != ','))
557
558 if (isalnum(c) || c == ':' || c == '_' || c == '*') {
559 do {
560 *p++ = c;
561 if ((size_t)(p-buf) >= sizeof(buf)) {
562 yyerror("string too long");
563 return (findeol());
564 }
565 } while ((c = lgetc(0)) != EOF(-1) && (allowed_in_string(c)(isalnum(c) || (ispunct(c) && c != '(' && c !=
')' && c != '{' && c != '}' && c != '<'
&& c != '>' && c != '!' && c != '='
&& c != '/' && c != '#' && c != ',')
)
));
566 lungetc(c);
567 *p = '\0';
568 if ((token = lookup(buf)) == STRING273)
569 if ((yylval.v.string = strdup(buf)) == NULL((void *)0))
570 fatal("yylex: strdup");
571 return (token);
572 }
573 if (c == '\n') {
574 yylval.lineno = file->lineno;
575 file->lineno++;
576 }
577 if (c == EOF(-1))
578 return (0);
579 return (c);
580}
581
582struct file *
583pushfile(const char *name)
584{
585 struct file *nfile;
586
587 if ((nfile = calloc(1, sizeof(struct file))) == NULL((void *)0)) {
588 log_warn("%s", __func__);
589 return (NULL((void *)0));
590 }
591 if ((nfile->name = strdup(name)) == NULL((void *)0)) {
592 log_warn("%s", __func__);
593 free(nfile);
594 return (NULL((void *)0));
595 }
596 if ((nfile->stream = fopen(nfile->name, "r")) == NULL((void *)0)) {
597 log_warn("%s: %s", __func__, nfile->name);
598 free(nfile->name);
599 free(nfile);
600 return (NULL((void *)0));
601 }
602 nfile->lineno = 1;
603 TAILQ_INSERT_TAIL(&files, nfile, entry)do { (nfile)->entry.tqe_next = ((void *)0); (nfile)->entry
.tqe_prev = (&files)->tqh_last; *(&files)->tqh_last
= (nfile); (&files)->tqh_last = &(nfile)->entry
.tqe_next; } while (0)
;
604 return (nfile);
605}
606
607int
608popfile(void)
609{
610 struct file *prev;
611
612 if ((prev = TAILQ_PREV(file, files, entry)(*(((struct files *)((file)->entry.tqe_prev))->tqh_last
))
) != NULL((void *)0))
613 prev->errors += file->errors;
614
615 TAILQ_REMOVE(&files, file, entry)do { if (((file)->entry.tqe_next) != ((void *)0)) (file)->
entry.tqe_next->entry.tqe_prev = (file)->entry.tqe_prev
; else (&files)->tqh_last = (file)->entry.tqe_prev;
*(file)->entry.tqe_prev = (file)->entry.tqe_next; ; ; }
while (0)
;
616 fclose(file->stream);
617 free(file->name);
618 free(file);
619 file = prev;
620 return (file ? 0 : EOF(-1));
621}
622
623int
624parse_config(const char *filename, struct radiusd *radiusd)
625{
626 int errors = 0;
627 struct radiusd_listen *l;
628 struct radiusd_module_ref *m, *mt;
629
630 conf = radiusd;
631 radiusd_conf_init(conf);
632 radiusd_authentication_init(&authen);
633 radiusd_client_init(&client);
634
635 if ((file = pushfile(filename)) == NULL((void *)0)) {
636 errors++;
637 goto out;
638 }
639 topfile = file;
640
641 yyparse();
642 errors = file->errors;
643 popfile();
644
645 if (TAILQ_EMPTY(&conf->listen)(((&conf->listen)->tqh_first) == ((void *)0))) {
646 if ((l = malloc(sizeof(struct radiusd_listen))) == NULL((void *)0)) {
647 log_warn("Out of memory");
648 return (-1);
649 }
650 l->stype = SOCK_DGRAM2;
651 l->sproto = IPPROTO_UDP17;
652 l->addr.ipv4.sin_family = AF_INET2;
653 l->addr.ipv4.sin_len = sizeof(struct sockaddr_in);
654 l->addr.ipv4.sin_addr.s_addr = htonl(0x7F000001L)(__uint32_t)(__builtin_constant_p(0x7F000001L) ? (__uint32_t)
(((__uint32_t)(0x7F000001L) & 0xff) << 24 | ((__uint32_t
)(0x7F000001L) & 0xff00) << 8 | ((__uint32_t)(0x7F000001L
) & 0xff0000) >> 8 | ((__uint32_t)(0x7F000001L) &
0xff000000) >> 24) : __swap32md(0x7F000001L))
;
655 l->addr.ipv4.sin_port = htons(RADIUS_DEFAULT_PORT)(__uint16_t)(__builtin_constant_p(1812) ? (__uint16_t)(((__uint16_t
)(1812) & 0xffU) << 8 | ((__uint16_t)(1812) & 0xff00U
) >> 8) : __swap16md(1812))
;
656 TAILQ_INSERT_TAIL(&conf->listen, l, next)do { (l)->next.tqe_next = ((void *)0); (l)->next.tqe_prev
= (&conf->listen)->tqh_last; *(&conf->listen
)->tqh_last = (l); (&conf->listen)->tqh_last = &
(l)->next.tqe_next; } while (0)
;
657 }
658 TAILQ_FOREACH(l, &conf->listen, next)for((l) = ((&conf->listen)->tqh_first); (l) != ((void
*)0); (l) = ((l)->next.tqe_next))
{
659 l->sock = -1;
660 }
661 radiusd_authentication_init(&authen);
662 TAILQ_FOREACH_SAFE(m, &authen.deco, next, mt)for ((m) = ((&authen.deco)->tqh_first); (m) != ((void *
)0) && ((mt) = ((m)->next.tqe_next), 1); (m) = (mt
))
{
663 TAILQ_REMOVE(&authen.deco, m, next)do { if (((m)->next.tqe_next) != ((void *)0)) (m)->next
.tqe_next->next.tqe_prev = (m)->next.tqe_prev; else (&
authen.deco)->tqh_last = (m)->next.tqe_prev; *(m)->next
.tqe_prev = (m)->next.tqe_next; ; ; } while (0)
;
664 free(m);
665 }
666out:
667 conf = NULL((void *)0);
668 return (errors ? -1 : 0);
669}
670
671static struct radiusd_module *
672find_module(const char *name)
673{
674 struct radiusd_module *module;
675
676 TAILQ_FOREACH(module, &conf->module, next)for((module) = ((&conf->module)->tqh_first); (module
) != ((void *)0); (module) = ((module)->next.tqe_next))
{
677 if (strcmp(name, module->name) == 0)
678 return (module);
679 }
680
681 return (NULL((void *)0));
682}
683
684static void
685free_str_l(void *str_l0)
686{
687 int i;
688 struct {
689 char **v;
690 int c;
691 } *str_l = str_l0;
692
693 for (i = 0; i < str_l->c; i++)
694 free(str_l->v[i]);
695 free(str_l->v);
696}
697
698static struct radiusd_module_ref *
699create_module_ref(const char *modulename)
700{
701 struct radiusd_module *module;
702 struct radiusd_module_ref *modref;
703
704 if ((module = find_module(modulename)) == NULL((void *)0)) {
705 yyerror("module `%s' is not found", modulename);
706 return (NULL((void *)0));
707 }
708 if ((modref = calloc(1, sizeof(struct radiusd_module_ref))) == NULL((void *)0)) {
709 yyerror("Out of memory: %s", strerror(errno(*__errno())));
710 return (NULL((void *)0));
711 }
712 modref->module = module;
713
714 return (modref);
715}
716
717static void
718radiusd_authentication_init(struct radiusd_authentication *auth)
719{
720 free(auth->auth);
721 memset(auth, 0, sizeof(struct radiusd_authentication));
722 TAILQ_INIT(&auth->deco)do { (&auth->deco)->tqh_first = ((void *)0); (&
auth->deco)->tqh_last = &(&auth->deco)->tqh_first
; } while (0)
;
723}
724
725static void
726radiusd_client_init(struct radiusd_client *clnt)
727{
728 memset(clnt, 0, sizeof(struct radiusd_client));
729 clnt->msgauth_required = true1;
730}
731#line 724 "parse.c"
732/* allocate initial stack or double stack size, up to YYMAXDEPTH */
733static int yygrowstack(void)
734{
735 unsigned int newsize;
736 long sslen;
737 short *newss;
738 YYSTYPE *newvs;
739
740 if ((newsize = yystacksize) == 0)
741 newsize = YYINITSTACKSIZE200;
742 else if (newsize >= YYMAXDEPTH10000)
743 return -1;
744 else if ((newsize *= 2) > YYMAXDEPTH10000)
745 newsize = YYMAXDEPTH10000;
746 sslen = yyssp - yyss;
747#ifdef SIZE_MAX0xffffffffffffffffUL
748#define YY_SIZE_MAX0xffffffffffffffffUL SIZE_MAX0xffffffffffffffffUL
749#else
750#define YY_SIZE_MAX0xffffffffffffffffUL 0xffffffffU
751#endif
752 if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newss)
753 goto bail;
754 newss = (short *)realloc(yyss, newsize * sizeof *newss);
755 if (newss == NULL((void *)0))
756 goto bail;
757 yyss = newss;
758 yyssp = newss + sslen;
759 if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newvs)
760 goto bail;
761 newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs);
762 if (newvs == NULL((void *)0))
763 goto bail;
764 yyvs = newvs;
765 yyvsp = newvs + sslen;
766 yystacksize = newsize;
767 yysslim = yyss + newsize - 1;
768 return 0;
769bail:
770 if (yyss)
771 free(yyss);
772 if (yyvs)
773 free(yyvs);
774 yyss = yyssp = NULL((void *)0);
775 yyvs = yyvsp = NULL((void *)0);
776 yystacksize = 0;
777 return -1;
778}
779
780#define YYABORTgoto yyabort goto yyabort
781#define YYREJECTgoto yyabort goto yyabort
782#define YYACCEPTgoto yyaccept goto yyaccept
783#define YYERRORgoto yyerrlab goto yyerrlab
784int
785yyparse(void)
786{
787 int yym, yyn, yystate;
788#if YYDEBUG0
789 const char *yys;
790
791 if ((yys = getenv("YYDEBUG")))
792 {
793 yyn = *yys;
794 if (yyn >= '0' && yyn <= '9')
795 yydebug = yyn - '0';
796 }
797#endif /* YYDEBUG */
798
799 yynerrs = 0;
800 yyerrflag = 0;
801 yychar = (-1);
802
803 if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow;
804 yyssp = yyss;
805 yyvsp = yyvs;
806 *yyssp = yystate = 0;
807
808yyloop:
809 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
810 if (yychar < 0)
811 {
812 if ((yychar = yylex()) < 0) yychar = 0;
813#if YYDEBUG0
814 if (yydebug)
815 {
816 yys = 0;
817 if (yychar <= YYMAXTOKEN274) yys = yyname[yychar];
818 if (!yys) yys = "illegal-symbol";
819 printf("%sdebug: state %d, reading %d (%s)\n",
820 YYPREFIX"yy", yystate, yychar, yys);
821 }
822#endif
823 }
824 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
825 yyn <= YYTABLESIZE264 && yycheck[yyn] == yychar)
826 {
827#if YYDEBUG0
828 if (yydebug)
829 printf("%sdebug: state %d, shifting to state %d\n",
830 YYPREFIX"yy", yystate, yytable[yyn]);
831#endif
832 if (yyssp >= yysslim && yygrowstack())
833 {
834 goto yyoverflow;
835 }
836 *++yyssp = yystate = yytable[yyn];
837 *++yyvsp = yylval;
838 yychar = (-1);
839 if (yyerrflag > 0) --yyerrflag;
840 goto yyloop;
841 }
842 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
843 yyn <= YYTABLESIZE264 && yycheck[yyn] == yychar)
844 {
845 yyn = yytable[yyn];
846 goto yyreduce;
847 }
848 if (yyerrflag) goto yyinrecovery;
849#if defined(__GNUC__4)
850 goto yynewerror;
851#endif
852yynewerror:
853 yyerror("syntax error");
854#if defined(__GNUC__4)
855 goto yyerrlab;
856#endif
857yyerrlab:
858 ++yynerrs;
859yyinrecovery:
860 if (yyerrflag < 3)
861 {
862 yyerrflag = 3;
863 for (;;)
864 {
865 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 &&
866 yyn <= YYTABLESIZE264 && yycheck[yyn] == YYERRCODE256)
867 {
868#if YYDEBUG0
869 if (yydebug)
870 printf("%sdebug: state %d, error recovery shifting\
871 to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]);
872#endif
873 if (yyssp >= yysslim && yygrowstack())
874 {
875 goto yyoverflow;
876 }
877 *++yyssp = yystate = yytable[yyn];
878 *++yyvsp = yylval;
879 goto yyloop;
880 }
881 else
882 {
883#if YYDEBUG0
884 if (yydebug)
885 printf("%sdebug: error recovery discarding state %d\n",
886 YYPREFIX"yy", *yyssp);
887#endif
888 if (yyssp <= yyss) goto yyabort;
889 --yyssp;
890 --yyvsp;
891 }
892 }
893 }
894 else
895 {
896 if (yychar == 0) goto yyabort;
897#if YYDEBUG0
898 if (yydebug)
899 {
900 yys = 0;
901 if (yychar <= YYMAXTOKEN274) yys = yyname[yychar];
902 if (!yys) yys = "illegal-symbol";
903 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
904 YYPREFIX"yy", yystate, yychar, yys);
905 }
906#endif
907 yychar = (-1);
908 goto yyloop;
909 }
910yyreduce:
911#if YYDEBUG0
912 if (yydebug)
913 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
914 YYPREFIX"yy", yystate, yyn, yyrule[yyn]);
915#endif
916 yym = yylen[yyn];
917 if (yym)
918 yyval = yyvsp[1-yym];
919 else
920 memset(&yyval, 0, sizeof yyval);
921 switch (yyn)
922 {
923case 9:
924#line 115 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
925{
926 struct file *nfile;
927
928 if ((nfile = pushfile(yyvsp[0].v.string)) == NULL((void *)0)) {
929 yyerror("failed to include file %s", yyvsp[0].v.string);
930 free(yyvsp[0].v.string);
931 YYERRORgoto yyerrlab;
932 }
933 free(yyvsp[0].v.string);
934
935 file = nfile;
936 lungetc('\n');
937 nfile->lineno--;
938 }
939break;
940case 10:
941#line 130 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
942{
943 struct radiusd_listen *n;
944
945 if ((n = malloc(sizeof(struct radiusd_listen)))
946 == NULL((void *)0)) {
947outofmemory:
948 yyerror("Out of memory: %s", strerror(errno(*__errno())));
949 YYERRORgoto yyerrlab;
950 }
951 *n = yyvsp[0].v.listen;
952 TAILQ_INSERT_TAIL(&conf->listen, n, next)do { (n)->next.tqe_next = ((void *)0); (n)->next.tqe_prev
= (&conf->listen)->tqh_last; *(&conf->listen
)->tqh_last = (n); (&conf->listen)->tqh_last = &
(n)->next.tqe_next; } while (0)
;
953 }
954break;
955case 11:
956#line 142 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
957{
958 int gai_errno;
959 struct addrinfo hints, *res;
960
961 memset(&hints, 0, sizeof(hints));
962 hints.ai_family = PF_UNSPEC0;
963 hints.ai_socktype = SOCK_DGRAM2;
964 hints.ai_flags = AI_PASSIVE1;
965 hints.ai_flags |= AI_NUMERICHOST4 | AI_NUMERICSERV16;
966
967 if ((gai_errno =
968 getaddrinfo(yyvsp[-1].v.string, NULL((void *)0), &hints, &res)) != 0 ||
969 res->ai_addrlen > sizeof(yyval.v.listen.addr)) {
970 yyerror("Could not parse the address: %s: %s",
971 yyvsp[-1].v.string, gai_strerror(gai_errno));
972 free(yyvsp[-1].v.string);
973 YYERRORgoto yyerrlab;
974 }
975 free(yyvsp[-1].v.string);
976 yyval.v.listen.stype = res->ai_socktype;
977 yyval.v.listen.sproto = res->ai_protocol;
978 memcpy(&yyval.v.listen.addr, res->ai_addr, res->ai_addrlen);
979 yyval.v.listen.addr.ipv4.sin_port = (yyvsp[0].v.number == 0)?
980 htons(RADIUS_DEFAULT_PORT)(__uint16_t)(__builtin_constant_p(1812) ? (__uint16_t)(((__uint16_t
)(1812) & 0xffU) << 8 | ((__uint16_t)(1812) & 0xff00U
) >> 8) : __swap16md(1812))
: htons(yyvsp[0].v.number)(__uint16_t)(__builtin_constant_p(yyvsp[0].v.number) ? (__uint16_t
)(((__uint16_t)(yyvsp[0].v.number) & 0xffU) << 8 | (
(__uint16_t)(yyvsp[0].v.number) & 0xff00U) >> 8) : __swap16md
(yyvsp[0].v.number))
;
981 freeaddrinfo(res);
982 }
983break;
984case 12:
985#line 168 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
986{ yyval.v.number = 0; }
987break;
988case 13:
989#line 169 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
990{ yyval.v.number = yyvsp[0].v.number; }
991break;
992case 14:
993#line 171 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
994{
995 radiusd_client_init(&client);
996 }
997break;
998case 15:
999#line 173 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1000{
1001 struct radiusd_client *client0;
1002
1003 if (client.secret[0] == '\0') {
1004 yyerror("secret is required for client");
1005 YYERRORgoto yyerrlab;
1006 }
1007
1008 client0 = calloc(1, sizeof(struct radiusd_client));
1009 if (client0 == NULL((void *)0))
1010 goto outofmemory;
1011 strlcpy(client0->secret, client.secret,
1012 sizeof(client0->secret));
1013 client0->msgauth_required = client.msgauth_required;
1014 client0->af = yyvsp[-4].v.prefix.af;
1015 client0->addr = yyvsp[-4].v.prefix.addr;
1016 client0->mask = yyvsp[-4].v.prefix.mask;
1017 TAILQ_INSERT_TAIL(&conf->client, client0, next)do { (client0)->next.tqe_next = ((void *)0); (client0)->
next.tqe_prev = (&conf->client)->tqh_last; *(&conf
->client)->tqh_last = (client0); (&conf->client)
->tqh_last = &(client0)->next.tqe_next; } while (0)
;
1018 }
1019break;
1020case 18:
1021#line 197 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1022{
1023 if (client.secret[0] != '\0') {
1024 free(yyvsp[0].v.string);
1025 yyerror("secret is specified already");
1026 YYERRORgoto yyerrlab;
1027 } else if (strlcpy(client.secret, yyvsp[0].v.string,
1028 sizeof(client.secret)) >= sizeof(client.secret)) {
1029 free(yyvsp[0].v.string);
1030 yyerror("secret is too long");
1031 YYERRORgoto yyerrlab;
1032 }
1033 free(yyvsp[0].v.string);
1034 }
1035break;
1036case 19:
1037#line 210 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1038{
1039 client.msgauth_required = yyvsp[0].v.yesno;
1040 }
1041break;
1042case 21:
1043#line 216 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1044{
1045 int gai_errno, q, r;
1046 struct addrinfo hints, *res;
1047
1048 memset(&hints, 0, sizeof(hints));
1049 hints.ai_family = PF_UNSPEC0;
1050 hints.ai_socktype = SOCK_DGRAM2; /* dummy */
1051 hints.ai_flags |= AI_NUMERICHOST4 | AI_NUMERICSERV16;
1052
1053 if ((gai_errno = getaddrinfo(yyvsp[-2].v.string, NULL((void *)0), &hints, &res))
1054 != 0) {
1055 yyerror("Could not parse the address: %s: %s",
1056 yyvsp[-2].v.string, gai_strerror(gai_errno));
1057 free(yyvsp[-2].v.string);
1058 YYERRORgoto yyerrlab;
1059 }
1060 free(yyvsp[-2].v.string);
1061 q = yyvsp[0].v.number >> 3;
1062 r = yyvsp[0].v.number & 7;
1063 switch (res->ai_family) {
1064 case AF_INET2:
1065 if (yyvsp[0].v.number < 0 || 32 < yyvsp[0].v.number) {
1066 yyerror("mask len %lld is out of range",
1067 (long long)yyvsp[0].v.number);
1068 YYERRORgoto yyerrlab;
1069 }
1070 yyval.v.prefix.addr.addr.ipv4 = ((struct sockaddr_in *)
1071 res->ai_addr)->sin_addr;
1072 yyval.v.prefix.mask.addr.ipv4.s_addr = htonl((uint32_t)(__uint32_t)(__builtin_constant_p((uint32_t) ((0xffffffffffULL
) << (32 - yyvsp[0].v.number))) ? (__uint32_t)(((__uint32_t
)((uint32_t) ((0xffffffffffULL) << (32 - yyvsp[0].v.number
))) & 0xff) << 24 | ((__uint32_t)((uint32_t) ((0xffffffffffULL
) << (32 - yyvsp[0].v.number))) & 0xff00) << 8
| ((__uint32_t)((uint32_t) ((0xffffffffffULL) << (32 -
yyvsp[0].v.number))) & 0xff0000) >> 8 | ((__uint32_t
)((uint32_t) ((0xffffffffffULL) << (32 - yyvsp[0].v.number
))) & 0xff000000) >> 24) : __swap32md((uint32_t) ((
0xffffffffffULL) << (32 - yyvsp[0].v.number))))
1073 ((0xffffffffffULL) << (32 - yyvsp[0].v.number)))(__uint32_t)(__builtin_constant_p((uint32_t) ((0xffffffffffULL
) << (32 - yyvsp[0].v.number))) ? (__uint32_t)(((__uint32_t
)((uint32_t) ((0xffffffffffULL) << (32 - yyvsp[0].v.number
))) & 0xff) << 24 | ((__uint32_t)((uint32_t) ((0xffffffffffULL
) << (32 - yyvsp[0].v.number))) & 0xff00) << 8
| ((__uint32_t)((uint32_t) ((0xffffffffffULL) << (32 -
yyvsp[0].v.number))) & 0xff0000) >> 8 | ((__uint32_t
)((uint32_t) ((0xffffffffffULL) << (32 - yyvsp[0].v.number
))) & 0xff000000) >> 24) : __swap32md((uint32_t) ((
0xffffffffffULL) << (32 - yyvsp[0].v.number))))
;
1074 break;
1075 case AF_INET624:
1076 if (yyvsp[0].v.number < 0 || 128 < yyvsp[0].v.number) {
1077 yyerror("mask len %lld is out of range",
1078 (long long)yyvsp[0].v.number);
1079 YYERRORgoto yyerrlab;
1080 }
1081 yyval.v.prefix.addr.addr.ipv6 = ((struct sockaddr_in6 *)
1082 res->ai_addr)->sin6_addr;
1083 memset(&yyval.v.prefix.mask.addr.ipv6, 0,
1084 sizeof(yyval.v.prefix.mask.addr.ipv6));
1085 if (q > 0)
1086 memset(&yyval.v.prefix.mask.addr.ipv6, 0xff, q);
1087 if (r > 0)
1088 *((u_char *)&yyval.v.prefix.mask.addr.ipv6 + q) =
1089 (0xff00 >> r) & 0xff;
1090 break;
1091 }
1092 yyval.v.prefix.af = res->ai_family;
1093 freeaddrinfo(res);
1094 }
1095break;
1096case 22:
1097#line 268 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1098{
1099 struct radiusd_module *module;
1100 if ((module = radiusd_module_load(conf, yyvsp[0].v.string, yyvsp[-1].v.string))
1101 == NULL((void *)0)) {
1102 free(yyvsp[-1].v.string);
1103 free(yyvsp[0].v.string);
1104 YYERRORgoto yyerrlab;
1105 }
1106 free(yyvsp[-1].v.string);
1107 free(yyvsp[0].v.string);
1108 TAILQ_INSERT_TAIL(&conf->module, module, next)do { (module)->next.tqe_next = ((void *)0); (module)->next
.tqe_prev = (&conf->module)->tqh_last; *(&conf->
module)->tqh_last = (module); (&conf->module)->tqh_last
= &(module)->next.tqe_next; } while (0)
;
1109 }
1110break;
1111case 23:
1112#line 280 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1113{
1114 struct radiusd_module *module;
1115
1116 module = find_module(yyvsp[-2].v.string);
1117 if (module == NULL((void *)0)) {
1118 yyerror("module `%s' is not found", yyvsp[-2].v.string);
1119setstrerr:
1120 free(yyvsp[-2].v.string);
1121 free(yyvsp[-1].v.string);
1122 free_str_l(&yyvsp[0].v.str_l);
1123 YYERRORgoto yyerrlab;
1124 }
1125 if (yyvsp[-1].v.string[0] == '_') {
1126 yyerror("setting `%s' is not allowed", yyvsp[-1].v.string);
1127 goto setstrerr;
1128 }
1129 if (radiusd_module_set(module, yyvsp[-1].v.string, yyvsp[0].v.str_l.c, yyvsp[0].v.str_l.v)) {
1130 yyerror("syntax error by module `%s'", yyvsp[-2].v.string);
1131 goto setstrerr;
1132 }
1133 free(yyvsp[-2].v.string);
1134 free(yyvsp[-1].v.string);
1135 free_str_l(&yyvsp[0].v.str_l);
1136 }
1137break;
1138case 25:
1139#line 307 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1140{ yyval.v.string = strdup("secret"); }
1141break;
1142case 26:
1143#line 310 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1144{
1145 radiusd_authentication_init(&authen);
1146 }
1147break;
1148case 27:
1149#line 312 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1150{
1151 struct radiusd_authentication *a;
1152
1153 if (authen.auth == NULL((void *)0)) {
1154 free_str_l(&yyvsp[-4].v.str_l);
1155 yyerror("no authentication module specified");
1156 YYERRORgoto yyerrlab;
1157 }
1158 if ((a = calloc(1,
1159 sizeof(struct radiusd_authentication))) == NULL((void *)0)) {
1160 free_str_l(&yyvsp[-4].v.str_l);
1161 goto outofmemory;
1162 }
1163 a->auth = authen.auth;
1164 authen.auth = NULL((void *)0);
1165 a->deco = authen.deco;
1166 a->username = yyvsp[-4].v.str_l.v;
1167
1168 TAILQ_INSERT_TAIL(&conf->authen, a, next)do { (a)->next.tqe_next = ((void *)0); (a)->next.tqe_prev
= (&conf->authen)->tqh_last; *(&conf->authen
)->tqh_last = (a); (&conf->authen)->tqh_last = &
(a)->next.tqe_next; } while (0)
;
1169 }
1170break;
1171case 30:
1172#line 338 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1173{
1174 struct radiusd_module_ref *modref;
1175
1176 if (authen.auth != NULL((void *)0)) {
1177 free(yyvsp[0].v.string);
1178 yyerror("authenticate is specified already");
1179 YYERRORgoto yyerrlab;
1180 }
1181 modref = create_module_ref(yyvsp[0].v.string);
1182 free(yyvsp[0].v.string);
1183 if (modref == NULL((void *)0))
1184 YYERRORgoto yyerrlab;
1185 authen.auth = modref;
1186 }
1187break;
1188case 31:
1189#line 352 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1190{
1191 int i;
1192 struct radiusd_module_ref *modref;
1193
1194 for (i = 0; i < yyvsp[0].v.str_l.c; i++) {
1195 if ((modref = create_module_ref(yyvsp[0].v.str_l.v[i]))
1196 == NULL((void *)0)) {
1197 free_str_l(&yyvsp[0].v.str_l);
1198 YYERRORgoto yyerrlab;
1199 }
1200 TAILQ_INSERT_TAIL(&authen.deco, modref, next)do { (modref)->next.tqe_next = ((void *)0); (modref)->next
.tqe_prev = (&authen.deco)->tqh_last; *(&authen.deco
)->tqh_last = (modref); (&authen.deco)->tqh_last = &
(modref)->next.tqe_next; } while (0)
;
1201 }
1202 free_str_l(&yyvsp[0].v.str_l);
1203 }
1204break;
1205case 33:
1206#line 368 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1207{
1208 int i;
1209 char **v;
1210 if ((v = calloc(sizeof(char **), yyval.v.str_l.c + 2)) == NULL((void *)0))
Result of 'calloc' is converted to a pointer of type 'char *', which is incompatible with sizeof operand type 'char **'
1211 goto outofmemory;
1212 for (i = 0; i < yyval.v.str_l.c; i++)
1213 v[i] = yyval.v.str_l.v[i];
1214 v[i++] = yyvsp[0].v.string;
1215 v[i] = NULL((void *)0);
1216 yyval.v.str_l.c++;
1217 free(yyval.v.str_l.v);
1218 yyval.v.str_l.v = v;
1219 }
1220break;
1221case 34:
1222#line 381 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1223{
1224 if ((yyval.v.str_l.v = calloc(sizeof(char **), 2)) == NULL((void *)0))
1225 goto outofmemory;
1226 yyval.v.str_l.v[0] = yyvsp[0].v.string;
1227 yyval.v.str_l.v[1] = NULL((void *)0);
1228 yyval.v.str_l.c = 1;
1229 }
1230break;
1231case 35:
1232#line 389 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1233{ yyval.v.string = yyvsp[0].v.string; }
1234break;
1235case 36:
1236#line 390 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1237{
1238 /* Treat number as a string */
1239 asprintf(&(yyval.v.string), "%jd", (intmax_t)yyvsp[0].v.number);
1240 if (yyval.v.string == NULL((void *)0))
1241 goto outofmemory;
1242 }
1243break;
1244case 39:
1245#line 400 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1246{ yyval.v.yesno = true1; }
1247break;
1248case 40:
1249#line 401 "/usr/src/usr.sbin/radiusd/radiusd/../parse.y"
1250{ yyval.v.yesno = false0; }
1251break;
1252#line 1245 "parse.c"
1253 }
1254 yyssp -= yym;
1255 yystate = *yyssp;
1256 yyvsp -= yym;
1257 yym = yylhs[yyn];
1258 if (yystate == 0 && yym == 0)
1259 {
1260#if YYDEBUG0
1261 if (yydebug)
1262 printf("%sdebug: after reduction, shifting from state 0 to\
1263 state %d\n", YYPREFIX"yy", YYFINAL1);
1264#endif
1265 yystate = YYFINAL1;
1266 *++yyssp = YYFINAL1;
1267 *++yyvsp = yyval;
1268 if (yychar < 0)
1269 {
1270 if ((yychar = yylex()) < 0) yychar = 0;
1271#if YYDEBUG0
1272 if (yydebug)
1273 {
1274 yys = 0;
1275 if (yychar <= YYMAXTOKEN274) yys = yyname[yychar];
1276 if (!yys) yys = "illegal-symbol";
1277 printf("%sdebug: state %d, reading %d (%s)\n",
1278 YYPREFIX"yy", YYFINAL1, yychar, yys);
1279 }
1280#endif
1281 }
1282 if (yychar == 0) goto yyaccept;
1283 goto yyloop;
1284 }
1285 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1286 yyn <= YYTABLESIZE264 && yycheck[yyn] == yystate)
1287 yystate = yytable[yyn];
1288 else
1289 yystate = yydgoto[yym];
1290#if YYDEBUG0
1291 if (yydebug)
1292 printf("%sdebug: after reduction, shifting from state %d \
1293to state %d\n", YYPREFIX"yy", *yyssp, yystate);
1294#endif
1295 if (yyssp >= yysslim && yygrowstack())
1296 {
1297 goto yyoverflow;
1298 }
1299 *++yyssp = yystate;
1300 *++yyvsp = yyval;
1301 goto yyloop;
1302yyoverflow:
1303 yyerror("yacc stack overflow");
1304yyabort:
1305 if (yyss)
1306 free(yyss);
1307 if (yyvs)
1308 free(yyvs);
1309 yyss = yyssp = NULL((void *)0);
1310 yyvs = yyvsp = NULL((void *)0);
1311 yystacksize = 0;
1312 return (1);
1313yyaccept:
1314 if (yyss)
1315 free(yyss);
1316 if (yyvs)
1317 free(yyvs);
1318 yyss = yyssp = NULL((void *)0);
1319 yyvs = yyvsp = NULL((void *)0);
1320 yystacksize = 0;
1321 return (0);
1322}