Bug Summary

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